嗨,我无法将列表视图中的项目列表打印到表格中。
lv.setOnItemClickListener(new OnItemClickListener() {
//@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String filename = ((TextView) view.findViewById(R.id.FileName)).getText().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(), QuestionActivity.class);
in.putExtra(KEY_FILENAME, filename);
startActivity(in);
}
});
单击项目时从第一页开始,它将传递到第二页。
在第二页检查 2 项时,我想将结果打印到表中,但出现错误。帮助!!!
if(checkedItems == 2){
Intent in1 = new Intent(getApplicationContext(), TableActivity.class);
String filename = ((TextView) arg1.findViewById(R.id.FileName)).getText().toString();
in1.putExtra(KEY_FILENAME, filename);
startActivity(in1);
}
logCat 看起来像这样
06-21 16:02:57.011: D/dalvikvm(422): GC_FOR_MALLOC 在 43 毫秒内释放了 2120 个对象/142168 个字节 06-21 16:02:59.931: D/AndroidRuntime(422): 关闭 VM 06-21 16:02 :59.931: W/dalvikvm(422): threadid=1: 线程以未捕获的异常退出 (group=0x4001d800) 06-21 16:02:59.941: E/AndroidRuntime(422): FATAL EXCEPTION: main 06-21 16:02 :59.941: E/AndroidRuntime(422): java.lang.NullPointerException 06-21 16:02:59.941: E/AndroidRuntime(422): at com.xml.android.QuestionActivity.onItemClick(QuestionActivity.java:119) 06- 21 16:02:59.941: E/AndroidRuntime(422): 在 android.widget.AdapterView.performItemClick(AdapterView.java:284) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 android.widget。 ListView.performItemClick(ListView.java:3382) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 android.widget.AbsListView$PerformClick.run(AbsListView.java:1696) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 android.os.Handler.handleCallback(Handler.java:587) 06-21 16:02:59.941: E/AndroidRuntime(422): 在android.os.Handler.dispatchMessage(Handler.java:92) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 android.os.Looper.loop(Looper.java:123) 06-21 16: 02:59.941: E/AndroidRuntime(422): 在 android.app.ActivityThread.main(ActivityThread.java:4627) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 java.lang.reflect.Method .invokeNative(Native Method) 06-21 16:02:59.941: E/AndroidRuntime(422): at java.lang.reflect.Method.invoke(Method.java:521) 06-21 16:02:59.941: E/ AndroidRuntime(422): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 06-21 16:02:59.941: E/AndroidRuntime(422): 在 com.android.internal.os .ZygoteInit.main(ZygoteInit.java:626) 06-21 16:02:59.941:E/AndroidRuntime(422): at dalvik.system.NativeStart.main(Native Method) 06-21 16:03:36.252: D/AndroidRuntime(447): 关闭 VM 06-21 16:03:36.262: W/dalvikvm (447): threadid=1: 线程以未捕获的异常退出 (group=0x4001d800) 06-21 16:03:36.272: E/AndroidRuntime(447): 致命异常: main 06-21 16:03:36.272: E/AndroidRuntime (447): java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.xml.android/com.xml.android.TableActivity}: java.lang.NullPointerException 06-21 16:03:36.272: E/AndroidRuntime(447 ): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 06- 21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread.access$2300(ActivityThread.java:125) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.os.Handler .dispatchMessage(Handler.java:99) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.os.Looper.loop(Looper.java:123) 06-21 16:03:36.272: E /AndroidRuntime(447): 在 android.app.ActivityThread.main(ActivityThread.java:4627) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 java.lang.reflect.Method.invokeNative(Native Method ) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 java.lang.reflect.Method.invoke(Method.java:521) 06-21 16:03:36.272: E/AndroidRuntime(447):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 com.android.internal.os.ZygoteInit.main( ZygoteInit.java:626) 06-21 16:03:36.272:E/AndroidRuntime(447): 在 dalvik.system.NativeStart.main(Native Method) 06-21 16:03:36.272: E/AndroidRuntime(447): 由: java.lang.NullPointerException 06-21 16:03: 36.272: E/AndroidRuntime(447): 在 com.xml.android.TableActivity.onCreate(TableActivity.java:27) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1047) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 06-21 16:03:36.272: E/AndroidRuntime (447): ... 11 更多E/AndroidRuntime(447): 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java :2627) 06-21 16:03:36.272: E/AndroidRuntime(447): ... 11 更多E/AndroidRuntime(447): 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 06-21 16:03:36.272: E/AndroidRuntime(447): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java :2627) 06-21 16:03:36.272: E/AndroidRuntime(447): ... 11 更多