gpt4 book ai didi

android - 异常 - 无法解析索引 6 处的属性 : TypedValue

转载 作者:IT老高 更新时间:2023-10-28 23:13:14 27 4
gpt4 key购买 nike

我看到以下异常:

04-06 13:35:58.498  4219  4219 E AndroidRuntime: android.view.InflateException: Binary XML file line #17: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x46 "res/color/abc_secondary_text_material_dark.xml" a=2 r=0x7f0e00e5}
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.support.v7.internal.view.menu.MenuPopupHelper$MenuAdapter.getView(MenuPopupHelper.java:374)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.support.v7.internal.view.menu.MenuPopupHelper.measureContentWidth(MenuPopupHelper.java:223)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.support.v7.internal.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:157)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.support.v7.widget.ActionMenuPresenter$OpenOverflowRunnable.run(ActionMenuPresenter.java:781)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x46 "res/color/abc_secondary_text_material_dark.xml" a=2 r=0x7f0e00e5}
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6890)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7071)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:446)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:386)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:385)
04-06 13:35:58.498 4219 4219 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:502)

当我单击工具栏中的菜单按钮时,这种情况已经发生了两次。不幸的是,这似乎是不可预测的,并且在多次尝试中发生了两次。我的菜单如下所示:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/menu_action_show_project_startup"
android:title="@string/menu_action_project_intro"
android:orderInCategory="300"
app:showAsAction="never"/>

<item android:id="@+id/menu_action_report_issue"
android:title="@string/menu_action_report_issue"
android:orderInCategory="300"
app:showAsAction="never"/>

<item android:id="@+id/menu_action_toggle_mobile_data"
android:checkable="true"
android:checked="true"
android:title="@string/menu_action_toggle_mobile_data"
android:orderInCategory="500"
app:showAsAction="never"/>

<item android:id="@+id/menu_action_logout"
android:title="@string/menu_action_logout"
android:orderInCategory="600"
app:showAsAction="never"/>

</menu>

我看过一个类似的问题 - Android XML: RuntimeException: Failed to resolve attribute at index 6 - 但我的问题似乎不是来自 FAB 按钮,我在我的应用程序中使用了 AppCompat。

最佳答案

基于 TaoBit 的上述解决方案,我意识到问题在于我的主题在 Marshmallow 中是 Not Acceptable 。所以我换了

<style name="Dark.Overlay" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">?attr/colorPrimary</item>
</style>

有了这个,一切都奏效了。感谢 TaoBit 的提示。您节省了 2 天的工作量和很多头痛。我每天都很喜欢。

<style name="MyToolbar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#FF0000</item>
<item name="android:textColorPrimary">#FFFFFF</item>
</style>

关于android - 异常 - 无法解析索引 6 处的属性 : TypedValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36451894/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com