zoukankan      html  css  js  c++  java
  • java.lang.UnsupportedOperationException: Can't convert to color: type=0x2 In TextInputLayout

    when we use TextInputLayout  to set 

    setErrorEnabled(true)

    it throws exception thus:

    09-26 17:46:04.650 19427-19427/com.ifreecomm.mst E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
                                                                           java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
                                                                               at android.content.res.TypedArray.getColor(TypedArray.java:327)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.inflate(AppCompatColorStateListInflater.java:114)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXmlInner(AppCompatColorStateListInflater.java:88)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXml(AppCompatColorStateListInflater.java:67)
                                                                               at android.support.v7.content.res.AppCompatResources.inflateColorStateList(AppCompatResources.java:116)
                                                                               at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:74)
                                                                               at android.support.v7.widget.TintTypedArray.getColorStateList(TintTypedArray.java:136)
                                                                               at android.support.v7.widget.AppCompatTextHelper.onSetTextAppearance(AppCompatTextHelper.java:157)
                                                                               at android.support.v7.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:148)
                                                                               at android.support.v4.widget.TextViewCompatGingerbread.setTextAppearance(TextViewCompatGingerbread.java:103)
                                                                               at android.support.v4.widget.TextViewCompat$BaseTextViewCompatImpl.setTextAppearance(TextViewCompat.java:86)
                                                                               at android.support.v4.widget.TextViewCompat.setTextAppearance(TextViewCompat.java:283)
                                                                               at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:609)
                                                                               at com.mst.v2.dialog.LoginDialog.onDataChangeListener(LoginDialog.java:288)
                                                                               at com.mst.v2.app.AppContext$1.handleMessage(AppContext.java:85)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                               at android.os.Looper.loop(Looper.java:136)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5111)
                                                                               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:786)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
                                                                               at dalvik.system.NativeStart.main(Native Method)

    the solution is adding 

    app:errorTextAppearance="@style/ErrorText"

    in the  TextInputLayout‘s xml.

    ErrorText.xml :
        <style name="ErrorText">
            <item name="android:textColor">@color/red</item>
            <item name="android:textSize">12sp</item>
        </style>
  • 相关阅读:
    利用 StartLoadingStatus 和 FinishLoadingStatus 读取数据特别是大数据时增加渐隐渐显等待特效
    在Indicator中添加动态Checkbox,无需绑定数据源,支持全选
    修复DBGrideh使用TMemTableEh在Footers求平均值为0的Bug
    字符串操作之格式化
    关于C#里面SQLite读取数据的操作
    多线程“尚未调用coinitialize” 报错
    自动化脚本运行稳定性(一)——脚本健壮性
    接口测试用例编写规范
    测试计划对应用质量的影响
    MySQL数据操作语句精解
  • 原文地址:https://www.cnblogs.com/jianglijs/p/7615672.html
Copyright © 2011-2022 走看看