android – SetError在TextInputLayout中使用自定义样式生成异常

我使用自定义样式在TextInputLayout中使用Edittext,以便我可以更改提示颜色.如果我在不设置样式的情况下使用EditText,则setError方法可以正常工作,但是我的样式设置会引发下一个异常:
java.lang.UnsupportedOperationException: Failed to resolve attribute at index 24: TypedValue{t=0x3/d=0x2b5 "res/color/secondary_text_material_dark.xml" a=1 r=0x1060166}
                                                                             at android.content.res.TypedArray.getColor(TypedArray.java:447)
                                                                             at android.widget.TextView.<init>(TextView.java:745)
                                                                             at android.widget.TextView.<init>(TextView.java:678)
                                                                             at android.widget.TextView.<init>(TextView.java:674)
                                                                             at android.widget.TextView.<init>(TextView.java:670)
                                                                             at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:380)
                                                                             at android.support.design.widget.TextInputLayout.setError(TextInputLayout.java:425)
                                                                             at com.wallakoala.wallakoala.Activities.SignUpUI.validateEmail(SignUpUI.java:50)
                                                                             at com.wallakoala.wallakoala.Activities.SignUpUI.access$100(SignUpUI.java:21)
                                                                             at com.wallakoala.wallakoala.Activities.SignUpUI$MyTextWatcher.afterTextChanged(SignUpUI.java:103)
                                                                             at android.widget.TextView.sendAfterTextChanged(TextView.java:8017)
                                                                             at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:10182)
                                                                             at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1043)
                                                                             at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:560)
                                                                             at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
                                                                             at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:34)
                                                                             at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
                                                                             at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:445)
                                                                             at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
                                                                             at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:224)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5526)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

这是EditText的XML

<android.support.design.widget.TextInputLayout
        android:id="@+id/email_input_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="34dp"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="12dp"
        android:theme="@style/TextLabel">

        <EditText
            android:id="@+id/email_edittext"
            android:inputType="textEmailAddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:textColor="@color/colorText"
            android:textColorHint="@color/colorMediumText"
            android:hint="@string/email_hint"
            android:nextFocusUp="@id/email_edittext"
            android:nextFocusLeft="@id/email_edittext"/>

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

这是styles.xml中定义的样式.

<style name="TextLabel" parent="TextAppearance.AppCompat">
    <item name="android:textColorHint">@color/colorLightText</item>
    <item name="android:textSize">14dp</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/colorMediumText</item>
    <item name="colorControlActivated">@color/colorAccent</item>
</style>

这是产生错误的行:

emailInputLayout.setError("Incorrect email");

知道发生了什么事吗?

提前致谢,

解决方法

我发现错误,这些属性必须是样式:
<item name="android:textColorHighlight">@color/COLOR</item>
<item name="android:textColorLink">@color/COLOR</item>

相关文章

以下为个人理解,如错请评 CE: 凭据加密 (CE) 存储空间, 实际路径/data/user_ce/ DE: 设备加密 (DE) 存...
转载来源:https://blog.csdn.net/yfbdxz/article/details/114702144 用EventLog.writeEvent打的日志(或...
事件分发机制详解 一、基础知识介绍 1、经常用的事件有:MotionEvent.ACTION_DOWN,MotionEvent.ACTION...
又是好久没有写博客了,一直都比较忙,最近终于有时间沉淀和整理一下最近学到和解决的一些问题。 最近进...
Android性能优化——之控件的优化 前面讲了图像的优化,接下来分享一下控件的性能优化,这里主要是面向...
android的开源库是用来在android上显示gif图片的。我在网上查了一下,大家说这个框架写的不错,加载大的...