尝试在android
中使用TextInputLayout时出错我有android支持库版本23.但仍然收到错误
我的xml文件显示错误
以下课程无法实例化:
- android.support.design.widget.TextInputLayout (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
11-25 00:58:30.967: E/AndroidRuntime(27848): Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
11-25 00:58:30.967: E/AndroidRuntime(27848): at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)
11-25 00:58:30.967: E/AndroidRuntime(27848): at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:103)
11-25 00:58:30.967: E/AndroidRuntime(27848): at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:96)
11-25 00:58:30.967: E/AndroidRuntime(27848): ... 24 more
11-25 13:32:29.967: E/AndroidRuntime(18136): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout" on path: DexPathList[[zip file "/data/app/com.odibly.android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.odibly.android-1/lib/arm, /vendor/lib, /system/lib]]
11-25 13:32:29.967: E/AndroidRuntime(18136): Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.TextInputLayout
答案 0 :(得分:4)
您需要在gradle文件中添加此依赖项
compile 'com.android.support:design:23.1.1'
答案 1 :(得分:4)
您需要将以下内容添加到模块build.gradle
文件中:
implementation 'com.google.android.material:material:1.0.0'
并在XML中使用 com.google.android.material.textfield.TextInputLayout :
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/my_hint">
答案 2 :(得分:0)
Definitelly,您需要在位于build.gradle
/app
文件中添加依赖项
dependencies {
...
implementation 'com.android.support:design:27.0.1' //change compile to implementation
...
}
}
但如果您仍在使用Eclipse,可能会在使用支持库时遇到一些问题,我建议您开始使用Android Studio。
<强> The Eclipse ADT plugin is no longer supported per our announcement. 强> Android Studio现在是Android的官方IDE,所以你应该这样做 尽快将项目迁移到Android Studio。更多 有关转换到Android Studio的信息,请参阅迁移到Android 来自Eclipse的Studio。