如何解决java.lang.UnsupportedOperationException

Pra*_*rma 5 android

请检查给定的代码.

我遇到问题引起:

java.lang.UnsupportedOperationException:无法解析索引24处的属性:TypedValue {t = 0x3/d = 0x30"res/color/primary_text_material_light.xml"a = 1 r = 0x10601ce}

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.AppBarLayout>

<RelativeLayout
    android:id="@+id/main_lays"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="60dp"
    android:padding="16dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/autoCompleteTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/fab_single"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/fab_single"
            android:background="@color/app_gray"
            android:gravity="center_vertical"
            android:hint="Contact name"
            android:padding="5dp"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_single"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/usersingle"
            app:backgroundTint="@color/colorPrimary" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="140dp"
        android:layout_alignParentBottom="true">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:theme="@style/TextLabel">

            <EditText
                android:id="@+id/messageEdittxt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:gravity="top|left"
                android:hint="Message"
                android:inputType="textMultiLine" />

        </android.support.design.widget.TextInputLayout>
    </RelativeLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的资源文件,如下所示

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="holo_blue">#FF33B5E5</color>
<color name="pressesd_color">#47348e</color>
<color name="default_color">#FFF</color>



<color name="colorPrimary">#125688</color>
<color name="app_gray">#b3b3b3</color>
<color name="colorPrimaryDark">#125688</color>
<color name="textColorPrimary">#FFFFFF</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#c8e8ff</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

请帮帮我.

Dan*_*son 2

造成这种情况的原因有很多,但我认为如果出现此问题,可以肯定地说您的主题出了问题。

对我来说,我正在定义一个主题:android:theme="@style/myTheme"在 a 上Button,并且由于复制粘贴错误而myTheme愚蠢地有一个父主题。parent="TextAppearance.AppCompat.Button"这意味着它找不到与按钮相关的资源。解决方法是使父级成为标准按钮主题:parent="@style/Widget.AppCompat.Button"

在OP中,我猜它android:theme="@style/TextLabel"有一个不相关的父母。这些确实应该有一些 lint 警告,样式非常复杂。