Most basic UI crash

by Jason Tai » Sun, 06 Apr 2008 13:06:15 GMT


Sponsored Links
 Hi,

Keep getting
   "Unable to start
activity...ComponentInfo{...}java.lang.NullPointerException"
error.

Tried couple of basic examples from web, same problem:

Actual Code:

public void onCreate(Bundle icicle)
{
        super.onCreate(icicle);

        setContentView(R.layout.enter_device_name);

        final Button button = (Button) findViewById(R.id.okButt);

        //
***********************************************************************************
        // If I remove the bottom statement, I can see the UI display; a
textedit and a abutton.
        // The line below causes the crash.
        //
***********************************************************************************
        button.setOnClickListener(
                new Button.OnClickListener()
                {
                        public void onClick(View v)
                        {
                        }
                }
        );
}

XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFEE9"   android:padding="10px">

    <TextView id="@+id/nameLab"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Type your name"/>

    <EditText id="@+id/yourName"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_below="@id/nameLab"/>

    <Button id="@+id/okButt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="10px"
            android:text="OK"
            android:layout_below="@id/yourName"/>

</RelativeLayout>

SDK: m5. Emulator using HVGA-P.

Also tried to use a dialog box. Also crashes when I call
setOnClickListener.

BTW, the 'okButt' button always display on top of the 'yourName' edit
box, isn't it suppose to be
'layout_below'? Other XML that I copied from some example exibit the
same behavior. Any clue?

Cheers...

Jason Tai
--~--~---------~--~----~------------~-------~--~----~



Most basic UI crash

by Dan U. » Sun, 06 Apr 2008 18:49:31 GMT


 Your layout file is in m3 format. 
 http://code.google.com/android/migrating/m3-to-m5/m5-api-changes.html 



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Most basic UI crash

by Jason Tai » Mon, 07 Apr 2008 00:27:02 GMT


 Aha!

It works!

Thanks a lot.

Jason Tai




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. will donut be available for the mytouch 3g, or just the g1?

will donut be available for the mytouch 3g or just the g1?

--~--~---------~--~----~------------~-------~--~----~

2. Movie.decodeStream(is) is returning NULL after updating to 1.5 SDK .

Hi Arvish,

This issue has been documented before (although I don't know if it's
officially listed as a bug yet), I haven't found a way around this
yes, either (apart from splitting the gif into several pngs,, i.e. one
png per frame).

Best regards,
Niko





--~--~---------~--~----~------------~-------~--~----~

3. is possible mapview and list exist in same activity

4. TextView

5. Buying a anroid Dev in Canada?

6. Starting service in separate thread

7. multiple selections in a gridview