首页新闻找找看学习计划

android 启动错误

0
[已解决问题] 解决于 2017-10-01 15:18

错误如下:

09-30 13:40:05.042 4628-4628/com.lyf.ai.demo E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.lyf.ai.demo, PID: 4628
                                                               java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lyf.ai.demo/com.lyf.ai.demo.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lyf.ai.demo/com.lyf.ai.demo.ActivityOne}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                   at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lyf.ai.demo/com.lyf.ai.demo.ActivityOne}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                   at android.app.ActivityThread.startActivityNow(ActivityThread.java:2465)
                                                                   at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
                                                                   at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
                                                                   at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:724)
                                                                   at android.widget.TabHost.setCurrentTab(TabHost.java:388)
                                                                   at android.widget.TabHost.addTab(TabHost.java:222)
                                                                   at com.lyf.ai.demo.MainActivity.initView(MainActivity.java:47)
                                                                   at com.lyf.ai.demo.MainActivity.onCreate(MainActivity.java:25)
                                                                   at android.app.Activity.performCreate(Activity.java:6679)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                   at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                   at com.lyf.ai.demo.ActivityOne.onCreate(ActivityOne.java:43)
                                                                   at android.app.Activity.performCreate(Activity.java:6679)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                   at android.app.ActivityThread.startActivityNow(ActivityThread.java:2465)
                                                                   at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
                                                                   at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
                                                                   at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:724)
                                                                   at android.widget.TabHost.setCurrentTab(TabHost.java:388)
                                                                   at android.widget.TabHost.addTab(TabHost.java:222)
                                                                   at com.lyf.ai.demo.MainActivity.initView(MainActivity.java:47)
                                                                   at com.lyf.ai.demo.MainActivity.onCreate(MainActivity.java:25)
                                                                   at android.app.Activity.performCreate(Activity.java:6679)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                   at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

 

Mr-LYF的主页 Mr-LYF | 菜鸟二级 | 园豆:201
提问于:2017-09-30 21:43
< >
分享
最佳答案
0

加载页面有误,建议查看setContentView(R.layout.activity_login);

奖励园豆:5
MISS_CM丶 | 菜鸟二级 |园豆:228 | 2017-10-01 15:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册