Hi,
My java code look like this :
// right_arrow button
ImageButton arrow_button = (ImageButton)findViewById
(R.id.arrow);
arrow_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
((View)v.getParent().getParent()).setSelected(true);
}
});
And the corresponding XML look like :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/row_layout" >
<LinearLayout android:id="@+id/row_checkbox_container">
<CheckBox android:id="@+id/row_checkbox" />
</LinearLayout>
<LinearLayout android:id="@+id/item_title_container">
<TextView android:id="@+id/item_title"/>
</LinearLayout>
<LinearLayout android:id="@+id/right_arrow_container" >
<ImageButton android:id="@+id/arrow"
android:layout_width="18px"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/arrow"
android:background="#00000000"/>
</LinearLayout>
</LinearLayout>
I got a null pointer exception right after running the app in the
emulator from eclipse on Ubuntu 8.10 :
E/AndroidRuntime( 1426): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.getincontext/com.getincontext.InContext}:
java.lang.NullPointerException
E/AndroidRuntime( 1426): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2141)
E/AndroidRuntime( 1426): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2157)
E/AndroidRuntime( 1426): at android.app.ActivityThread.access$1800
(ActivityThread.java:112)
E/AndroidRuntime( 1426): at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1581)
E/AndroidRuntime( 1426): at android.os.Handler.dispatchMessage
(Handler.java:88)
E/AndroidRuntime( 1426): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1426): at android.app.ActivityThread.main
(ActivityThread.java:3739)
E/AndroidRuntime( 1426): at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime( 1426): at java.lang.reflect.Method.invoke
(Method.java:515)
E/AndroidRuntime( 1426): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime( 1426): at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:497)
E/AndroidRuntime( 1426): at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 1426): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 1426): at com.getincontext.InContext.onCreate
(InContext.java:51)
E/AndroidRuntime( 1426): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1122)
E/AndroidRuntime( 1426): at
android.app.ActivityThread.performLaunchActiv
I searched in the other posts something similar, and It seems that it
must be because the ImageButton is set to null.
Unfortunately I can't find anything that would lead to it in the XML
or the Java code. The button is displayed properly and eclipse does
not detect any error. I guess this is runtime.
I tried to cast from ImageButton to button but it doesn't change
anything. So I image the trouble is from findViewById(), but arrow to
exists, is a regular pgn file and is displayed by the emulator if this
line is commented.
The weirdest is that I got a similar statement just above, and I can't
see any difference.
Any clue ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---