Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

android - RuntimeException while using new TextInputLayout from support design library

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

to your build.gradle


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...