gpt4 book ai didi

android - 无法在 TextInputLayout 上扩充 ColorStateList

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:20:57 31 4
gpt4 key购买 nike

我正在尝试使用 TextInputLayouts 制作登录屏幕。但是我无法显示错误。我在 LogCat 上收到下一个错误,但错误没有出现。

E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
java.lang.UnsupportedOperationException: Can't convert to color: type=0x2

我有一些下一个组件。

<android.support.design.widget.TextInputLayout
android:id="@+id/til_email"
android:layout_width="match_parent"
android:layout_height="@dimen/textinput_height">

<android.support.v7.widget.AppCompatEditText
android:id="@+id/et_email"
android:layout_width="match_parent"
android:layout_height="@dimen/textinput_height"
android:drawableLeft="@drawable/ic_face"
android:drawableStart="@drawable/ic_face"
android:drawablePadding="8dp"
android:hint="@string/str_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textColor="@color/blue"
android:typeface="normal" />
</android.support.design.widget.TextInputLayout>

我不知道如何解决这个失败。有人可以告诉我一些建议吗?

谢谢。

堆栈跟踪

06-22 09:26:46.897 1853-1853/com.ikomobi.SuscribeApp 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:326)
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.ikomobi.SuscribeApp.ui.login.LoginFragment.setUp(LoginFragment.java:81)
at com.ikomobi.SuscribeApp.ui.login.LoginFragment.onCreateView(LoginFragment.java:73)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
06-22 09:26:46.897 1853-1853/com.ikomobi.SuscribeApp 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:326)
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.ikomobi.SuscribeApp.ui.login.LoginFragment.setUp(LoginFragment.java:82)
at com.ikomobi.SuscribeApp.ui.login.LoginFragment.onCreateView(LoginFragment.java:73)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

最佳答案

我在使用 TextInputLayout 和设置 errorEnabled 时遇到了同样的错误

我通过向我的自定义 App 主题添加 textColorError 解决了这个问题:

<style name="YOURCUSTOMTHEME" parent="YOUR.PARENT.THEME">
<!-- ..... other styles -->
<item name="textColorError">@color/YOUR_COLOR</item>
</style>

关于android - 无法在 TextInputLayout 上扩充 ColorStateList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44692964/

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