扩展类android.widget.CheckBox时出错

时间:2016-04-11 16:50:32

标签: android xml checkbox android-preferences

请帮助,我的pref_general.xml文件存在一些问题,因为我发现了应用程序发现的SettingsActivity(PreferenceActivity),我收到以下错误消息:

  

android.view.InflateException:二进制XML文件行#19:错误膨胀类android.widget.CheckBox

然后logcat将该行指向我的PreferenceActivity,我称之为“addPreferencesFromResource(R.xml.pref_general);”

经过几个小时的尝试解决后,我仍然不知道问题是什么,所以也许有人对此很熟悉,或者只是另一组眼睛就能找到问题。

此外,我在Android 5.1中尝试这一切很好,但在Android Api 19(在我的手机中)什么都没有用?

android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.CheckBox
at android.view.LayoutInflater.createView(LayoutInflater.java:627)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:676)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:701)
at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.preference.Preference.onCreateView(Preference.java:531)
at android.preference.Preference.getView(Preference.java:494)
at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:222)
at android.widget.AbsListView.obtainView(AbsListView.java:2351)
at android.widget.ListView.makeAndAddView(ListView.java:1816)
at android.widget.ListView.fillDown(ListView.java:697)
at android.widget.ListView.fillFromTop(ListView.java:763)
at android.widget.ListView.layoutChildren(ListView.java:1646)
at android.widget.AbsListView.onLayout(AbsListView.java:2207)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1692)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1534)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1443)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1692)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1677)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1445)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1692)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1534)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1443)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1692)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1534)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1443)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15033)
at android.view.ViewGroup.layout(ViewGroup.java:4799)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2143)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1062)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5998)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5590)
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:1280)
at com.android.int

全部感谢= D

1 个答案:

答案 0 :(得分:8)

支持库的版本23.2.0中有bug可能导致此问题。

这在图书馆的修订版23.2.1中得到修复。此版本声明以下我认为是问题的根本原因,并解释了为什么它只能在运行API 19的手机上失败:

  

修复了API上的DrawableCompat.wrap()和LayerDrawable中的异常   等级17至19。