Cooke_
2015-10-13 11:56
采纳率: 50%
浏览 2.2k
已采纳

setAdapter时空指针异常

本人新手,望解答
谢谢
10-13 19:53:37.732: E/AndroidRuntime(12285): FATAL EXCEPTION: main
10-13 19:53:37.732: E/AndroidRuntime(12285): Process: com.example.mydemo, PID: 12285
10-13 19:53:37.732: E/AndroidRuntime(12285): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.example.mydemo.SubFragment1$MyTask.onPostExecute(SubFragment1.java:131)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.example.mydemo.SubFragment1$MyTask.onPostExecute(SubFragment1.java:1)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask.finish(AsyncTask.java:632)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask.access$600(AsyncTask.java:177)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.Handler.dispatchMessage(Handler.java:102)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.Looper.loop(Looper.java:155)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.app.ActivityThread.main(ActivityThread.java:5696)
10-13 19:53:37.732: E/AndroidRuntime(12285): at java.lang.reflect.Method.invoke(Native Method)
10-13 19:53:37.732: E/AndroidRuntime(12285): at java.lang.reflect.Method.invoke(Method.java:372)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

代码如下
10-13 19:53:37.732: E/AndroidRuntime(12285): FATAL EXCEPTION: main
10-13 19:53:37.732: E/AndroidRuntime(12285): Process: com.example.mydemo, PID: 12285
10-13 19:53:37.732: E/AndroidRuntime(12285): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.example.mydemo.SubFragment1$MyTask.onPostExecute(SubFragment1.java:131)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.example.mydemo.SubFragment1$MyTask.onPostExecute(SubFragment1.java:1)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask.finish(AsyncTask.java:632)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask.access$600(AsyncTask.java:177)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.Handler.dispatchMessage(Handler.java:102)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.os.Looper.loop(Looper.java:155)
10-13 19:53:37.732: E/AndroidRuntime(12285): at android.app.ActivityThread.main(ActivityThread.java:5696)
10-13 19:53:37.732: E/AndroidRuntime(12285): at java.lang.reflect.Method.invoke(Native Method)
10-13 19:53:37.732: E/AndroidRuntime(12285): at java.lang.reflect.Method.invoke(Method.java:372)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
10-13 19:53:37.732: E/AndroidRuntime(12285): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题