1

我正在尝试将“TextInputLayout”与“TextInputEditText”一起使用。我已经浏览了stackoverflow中的帖子,但没有任何帮助。

这是我非常简单的代码 -

XML设计:

<?xml version="1.0" encoding="utf-8"?>
<TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent">
    <android.support.design.widget.TextInputEditText
        android:id="@+id/tv_card_expiration"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="date"
        android:hint="crap"
        android:paddingStart="10dp"
        android:textSize="20sp"/>
</TextInputLayout>

通货膨胀代码(在我的片段中):

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState)
{
    return inflater.inflate(R.layout.fragment_purchase, container, false);
}

运行时,返回以下异常:

android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class TextInputLayout
                                                                                     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class TextInputLayout
                                                                                     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.TextInputLayout" on path: DexPathList[[zip file "/data/app/com.javaproject.pashnim.pashnimcinema-1/base.apk"],nativeLibraryDirectories=[/data/app/com.javaproject.pashnim.pashnimcinema-1/lib/x86, /system/lib, /vendor/lib]]
                                                                                         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                                         at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                                                         at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                         at android.view.LayoutInflater.createView(LayoutInflater.java:609)
                                                                                         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:700)
                                                                                         at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
                                                                                         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
                                                                                         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
                                                                                         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
                                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                                                         at com.javaproject.pashnim.cinema.PurchaseFinishFragment.onCreateView(PurchaseFinishFragment.java:23)

或简而言之:

引起:java.lang.ClassNotFoundException:在路径上找不到类“android.view.TextInputLayout”:DexPathList [[zip file“/data/app/com.javaproject.pashim.pashnicinema-1/base.apk”] ,nativeLibraryDirectories=[/data/app/com.javaproject.pashim.pashimcinema-1/lib/x86, /system/lib, /vendor/lib]]

备注:

  1. 我正在运行 Android Studio 3.0 Canary V9
  2. Gradle 版本:“3.0.0-alpha9”
  3. 我添加了所需的依赖项:

编译'com.android.support:design:25.3.1'

  1. 尝试清理重建项目。

有什么想法吗?

4

0 回答 0