eption的同时采用新的TextInputLayout从支持设

eption的同时采用新的TextInputLayout从支持设

本文介绍了RuntimeException的同时采用新的TextInputLayout从支持设计库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有非常简单的布局,在那里我使用的

 < android.support.design.widget.TextInputLayout
    机器人:ID =@ + ID /直到
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT>
    <的EditText
        机器人:ID =@ + ID / textDialog
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:提示=名/>
< /android.support.design.widget.TextInputLayout>
 

在充气我得到异常:

 产生的原因:java.lang.RuntimeException的:无法解析属性索引18
            在android.content.res.TypedArray.getColor(TypedArray.java:401)
            在android.support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:166)
            在android.support.design.widget.TextInputLayout< INIT>(TextInputLayout.java:106)
在java.lang.reflect.Constructor.newInstance(本机方法)
在java.lang.reflect.Constructor.newInstance(Constructor.java:288)
在android.view.LayoutInflater.createView(LayoutInflater.java:607)
在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
在android.view.LayoutInflater.inflate(LayoutInflater.java:504)
在android.view.LayoutInflater.inflate(LayoutInflater.java:414)
在android.view.LayoutInflater.inflate(LayoutInflater.java:365)
在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
在android.app.Activity.setContentView(Activity.java:2144)
在com.example.trybindinglib.MainActivity.onCreate(MainActivity.java:24)
在android.app.Activity.performCreate(Activity.java:5933)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
在android.app.ActivityThread.access $ 800(ActivityThread.java:149)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1324)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:211)
在android.app.ActivityThread.main(ActivityThread.java:5321)
在java.lang.reflect.Method.invoke(本机方法)
在java.lang.reflect.Method.invoke(Method.java:372)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1016)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
 

解决方案

你添加的设计支持库?添加依赖性:

 编译com.android.support:design:22.2.0
 

您build.gradle

I have very simple layout where I use new android.support.design.widget.TextInputLayout view from Design Support Library

<android.support.design.widget.TextInputLayout
    android:id="@+id/til"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <EditText
        android:id="@+id/textDialog"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="First Name"/>
</android.support.design.widget.TextInputLayout>

On inflate I get exception:

Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 18
            at android.content.res.TypedArray.getColor(TypedArray.java:401)
            at android.support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:166)
            at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:106)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
            at android.view.LayoutInflater.createView(LayoutInflater.java:607)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
            at android.app.Activity.setContentView(Activity.java:2144)
            at com.example.trybindinglib.MainActivity.onCreate(MainActivity.java:24)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
            at android.app.ActivityThread.access$800(ActivityThread.java:149)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:211)
            at android.app.ActivityThread.main(ActivityThread.java:5321)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
解决方案

Have you added the Design Support Library?Add the dependency:

compile 'com.android.support:design:22.2.0'

to your build.gradle

这篇关于RuntimeException的同时采用新的TextInputLayout从支持设计库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:32