LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Mobile
User Name
Password
Linux - Mobile This forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Firefox OS, Sailfish OS, Maemo, MeeGo, Ubuntu Mobile, WebOS, Open Mobile Alliance and other similar projects and products.
A reminder that LQ now has a dedicated Android sister site: AndroidQuestions.org

Notices



Reply
 
Search this Thread
Old 09-02-2010, 11:22 PM   #1
firmlyjin
LQ Newbie
 
Registered: Mar 2009
Posts: 4

Rep: Reputation: 0
my first activity runing happen error:Uncaught handler: thread main exiting due to un


hrloo.java

view plaincopy to clipboardprint?
package hello.pak;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class hrllo_act<heloo> extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.go);
btn.setOnClickListener(new View.OnClickListener()
{

public void onClick(View v) {
EditText edt=(EditText)findViewById(R.id.edt);

TextView txt= (TextView)findViewById(R.id.txt);
txt.setText(getString(R.string.go)+edt.getText());

}
});
}
}


main.xml
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText id="@+id/edt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
<Button id="@+id/go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/go">
<requestFocus />
</Button>
</LinearLayout>


strings.xml
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, hrllo_act!</string>
<string name="app_name">heloo_app</string>
<string name="go">go,go,go</string>
</resources>



i think maybe folowing code have error:
view plaincopy to clipboardprint?
EditText edt=(EditText)findViewById(R.id.edt);

TextView txt= (TextView)findViewById(R.id.txt);


thank you!
 
Old 09-03-2010, 05:43 PM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

You simply need to add a try/catch block to your code. That will help you resolve this problem. It's also good practice for ALL of your code.

This link might help:
http://davidjhinson.wordpress.com/20...ch-everything/

ALSO: you might want to use "logcat" while running your program (I assume you're running in the emulator for now):

http://developer.android.com/guide/d...tools/adb.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the return value of getpid() called from main thread and new thread r identical !!! cryincold Programming 3 02-29-2008 02:37 AM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 10:15 AM
KDE crash handler when exiting programs Klas Mandriva 9 08-30-2004 12:03 AM
Exiting program w/ pthreads from sig handler LogicG8 Programming 1 07-29-2004 06:56 PM
Why do i get segmentation fault upon exiting main() J-Ral Programming 5 05-28-2004 05:27 AM


All times are GMT -5. The time now is 07:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration