安卓错误:膨胀类TextInputLayout。

4
我正在尝试在我的XML中使用TextInputLayout,但遇到了以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.jechange.moncompte/fr.jechange.moncompte.SignUpActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;

我已经导入了设计库以及support-v7-appcompat库。同时使用的是Theme.AppCompat.Light.NoActionBar主题。

我正在使用的XML中包含类似于以下内容的文本输入布局(Text Input Layout)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
style="@style/matchParent">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:inputType="text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>
</RelativeLayout>

请确保在lib文件夹中有v7 jar文件。 - Sachin Chandil
我尝试了但是没有效果。但是目前,我已经将我的项目与support-v7-appcompat库链接起来了,所以我不需要添加v7 jar文件了吗?(我总是在处理库、jar等方面遇到问题。) - deveLost
好的,那么在我的情况下,v7 jar没有被添加到我的项目中。但是我手动添加了它,这并不能解决我的问题 :/ - deveLost
你使用哪个集成开发环境(IDE)? - Sachin Chandil
我已经尝试删除所有的库/ JAR 文件,并重新导入它们,但是还是不起作用 :/ - deveLost
显示剩余3条评论
2个回答

1
如果您从活动中调用包含TextInputLayout的布局,则无需使用getApplicationcontext或YourApplicationClassName.getcontext()或其他传递上下文的方法,只需使用YouActivityClassName.this即可。

0
我有同样的问题,这里已经修复。 确保你没有导入v4和v7以外的其它支持库,你只能使用design-support库。同时,你还应该确保你的主题“matchParent”从Theme.AppCompat继承,适用于你尝试运行的所有平台。 我的问题只出现在Lollipop上,因为values-21/style.xml。 希望这能有所帮助。

1
没事了,可能是因为重启了几次Eclipse,现在它可以工作了...哈哈... - deveLost
我的样式继承自Theme.AppCompat.Light.NoActionBar,希望这样可以。 - Edijae Crusar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接