我有两个类 page1 和 page2。单击page1中的按钮时,如何将数据从page1传输到page2中的整数
我尝试了几个代码: Page1.Class
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent i = null;
switch (position)
{
case 0:
i = new Intent(this, page2.class );
i.putExtra("Konum", 2);
break;
}
startActivity(i);
Page2.Class
Intent intent = getIntent();
private Integer konum = intent.getIntExtra("Konum", 0);
但不起作用! 单击page1中的按钮时,如何将数据从page1传输到page2中的整数
错误:
09-27 19:50:19.556: E/AndroidRuntime(528): FATAL EXCEPTION: main
09-27 19:50:19.556: E/AndroidRuntime(528): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ru.truba.touchgallery/ru.truba.touchgallery.GalleryUrlActivity}: java.lang.NullPointerException
09-27 19:50:19.556: E/AndroidRuntime(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.os.Looper.loop(Looper.java:123)
09-27 19:50:19.556: E/AndroidRuntime(528): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-27 19:50:19.556: E/AndroidRuntime(528): at java.lang.reflect.Method.invokeNative(Native Method)