Java.lang.UnsupportedOperationException:Can ' t convert to color:type=0x2 in Textinputlayout

Source: Internet
Author: User

When we use the 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.AppCompa Tcolorstatelistinflater.inflate (Appcompatcolorstatelistinflater.java:114) at Android.support.v7.content.res.AppCompa Tcolorstatelistinflater.createfromxmlinner (Appcompatcolorstatelistinflater.java:88) at Android.support.v7.content.res.AppCompa Tcolorstatelistinflater.createfromxml (Appcompatcolorstatelistinflater.java:67) at Android.support.v7.content.res.AppCompa Tresources.inflatecolorstatelist (Appcompatresources.java:116) at Android.support.v7.content.res.AppCompa Tresources.getcolorstatelist (Appcompatresources.java:74) at Android.support.v7.widget.TintTypedArra Y.getcolorstatelist (Tinttypedarray.java:136) at Android.support.v7.widget.AppCompatText Helper.onsettextappearance (Appcompattexthelper.java:157) at Android.support.v7.widget.AppCompatText View.settextappearance (Appcompattextview.java:148) at Android.support.v4.widget.TextViewCompa Tgingerbread.settextappearance (Textviewcompatgingerbread.java:103) at Android.support.v4.widget.TextViewCompa T$basetextviewcompatimpl.settextappearance (Textviewcompat.java:86) at Android.support.v4.widget.TextViewCompa T.settextappearance (Textviewcompat.java:283) at Android.support.design.widget.TextInput Layout.seterrorenabled (Textinputlayout.java:609) at Com.mst.v2.dialog.LoginDialog.onDataCha Ngelistener (Logindialog.java:288) at com.mst.v2.app.appcontext$1.handleMessage (appcontext.java:85) at Android.os.Handler.dispatchMessage (Hand Ler.java:102) at Android.os.Looper.loop (looper.java:136) at Android.app.ActivityThread.main (Activit Ythread.java:5111) at Java.lang.reflect.Method.invokeNative (N Ative Method) at Java.lang.reflect.Method.invoke (Method.java:515) at Com.android.internal.os.zygoteinit$meth Odandargscaller.run (Zygoteinit.java:786) at Com.android.internal.os.ZygoteInit.main (Zygoteinit.java:602) at Dalvik.system.NativeStart.main (Native M Ethod)

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>

Java.lang.UnsupportedOperationException:Can ' t convert to color:type=0x2 in Textinputlayout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.