Android setContentView 的时候包空指针异常

蜡笔小小小新 发布于 2016/04/22 16:15
阅读 771
收藏 0

Android setContentView 的时候包空指针异常。

代码:


异常:

04-22 04:08:25.434 26417-26417/com.jeanselam.activities E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.jeanselam.activities, PID: 26417
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jeanselam.activities/com.jeanselam.activities.DisplayNewsActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class null
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:136)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:515)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                              at dalvik.system.NativeStart.main(Native Method)
                                                                           Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class null
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
                                                                              at com.jeanselam.activities.DisplayNewsActivity.onCreate(DisplayNewsActivity.java:33)
                                                                              at android.app.Activity.performCreate(Activity.java:5231)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:136)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:515)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                              at dalvik.system.NativeStart.main(Native Method)
                                                                           Caused by: java.lang.NullPointerException
                                                                              at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:90)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
                                                                              at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
                                                                              at com.jeanselam.activities.DisplayNewsActivity.onCreate(DisplayNewsActivity.java:33)
                                                                              at android.app.Activity.performCreate(Activity.java:5231)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:136)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:515)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                              at dalvik.system.NativeStart.main(Native Method)

加载中
0
uuttxt
uuttxt

找到原因了吗

返回顶部
顶部