view.inflate异常:Binary XML file line #34: Error inflating class null

前端之家收集整理的这篇文章主要介绍了view.inflate异常:Binary XML file line #34: Error inflating class null前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.现象:

自定义类:public class SettingItemView extends RelativeLayout

view组件构造方法调用View.inflate(context,R.layout.setting_item,this);时FC。

log:

07-19 05:46:15.493: W/dalvikvm(1240): threadid=1: thread exiting with uncaught exception (group=0xb39f7ba8)
07-19 05:46:16.243: E/AndroidRuntime(1240): FATAL EXCEPTION: main
07-19 05:46:16.243: E/AndroidRuntime(1240): Process: com.honeybee.mobilesafe,PID: 1240
07-19 05:46:16.243: E/AndroidRuntime(1240): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.honeybee.mobilesafe/com.honeybee.mobilesafe.SettingActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class com.honeybee.mobilesafe.ui.SettingItemView
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.os.Handler.dispatchMessage(Handler.java:102)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.os.Looper.loop(Looper.java:136)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-19 05:46:16.243: E/AndroidRuntime(1240): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 05:46:16.243: E/AndroidRuntime(1240): at java.lang.reflect.Method.invoke(Method.java:515)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-19 05:46:16.243: E/AndroidRuntime(1240): at dalvik.system.NativeStart.main(Native Method)
07-19 05:46:16.243: E/AndroidRuntime(1240): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.honeybee.mobilesafe.ui.SettingItemView
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.Activity.setContentView(Activity.java:1929)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.honeybee.mobilesafe.SettingActivity.onCreate(SettingActivity.java:12)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.Activity.performCreate(Activity.java:5231)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
07-19 05:46:16.243: E/AndroidRuntime(1240): ... 11 more
07-19 05:46:16.243: E/AndroidRuntime(1240): Caused by: java.lang.reflect.InvocationTargetException
07-19 05:46:16.243: E/AndroidRuntime(1240): at java.lang.reflect.Constructor.constructNative(Native Method)
07-19 05:46:16.243: E/AndroidRuntime(1240): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
07-19 05:46:16.243: E/AndroidRuntime(1240): ... 22 more
07-19 05:46:16.243: E/AndroidRuntime(1240): Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class null
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-19 05:46:16.243: E/AndroidRuntime(1240): at android.view.View.inflate(View.java:17465)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.honeybee.mobilesafe.ui.SettingItemView.initView(SettingItemView.java:14)
07-19 05:46:16.243: E/AndroidRuntime(1240): at com.honeybee.mobilesafe.ui.SettingItemView.<init>(SettingItemView.java:24)
07-19 05:46:16.243: E/AndroidRuntime(1240): ... 25 more

2.原因:

布局文件中<View/>组件应该为大写V

原文链接:https://www.f2er.com/xml/296458.html

猜你在找的XML相关文章