Недостающие классы android.support.v7.widget.CardView - PullRequest
0 голосов
/ 17 октября 2019

У меня есть приложение для распознавания текста из этого учебного пособия , но мой макет вызывает некоторые проблемы

Не удалось найти следующие классы:

android. support.v7.widget.CardView

Результат ожидания

Реальный текущий результат

Что я пропустил илиделать неправильно?

приложение build.gradle :

implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

Activity_main

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardBackgroundColor="#fff"
            app:cardUseCompatPadding="true"
            app:cardCornerRadius="3dp"
            app:cardElevation="3dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="5dp">
                <TextView
                    android:text="Result"
                    android:textColor="@color/colorPrimary"
                    android:textSize="20sp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <EditText
                    android:id="@+id/resultET"
                    android:hint=""
                    android:autoLink="all"
                    android:padding="5dp"
                    android:background="@null"
                    android:textColor="#000"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:autofillHints=""/>
            </LinearLayout>
      </android.support.v7.widget.CardView>
   </LinearLayout>
 </ScrollView>
</RelativeLayout>

Ответы [ 3 ]

1 голос
/ 17 октября 2019

Кроме замены

com.android.support:cardview-v7:28.0.0

на

androidx.cardview:cardview:1.0.0

вам все еще нужно заменить xml и импортировать объект из

android.support.v7.widget.CardView

в

androidx.cardview.widget.CardView

Кстати, другие компоненты тоже должны быть заменены. например:

в Gradle

implementation 'androidx.recyclerview:recyclerview:1.0.0'

в коде и объект XML будет

androidx.recyclerview.widget.RecyclerView
0 голосов
/ 17 октября 2019

В Java - теперь вы можете использовать

import androidx.cardview.widget.CardView;

В build.gradle -

реализация 'androidx.cardview: cardview: 1.0.0'

0 голосов
/ 17 октября 2019

, если вы делаете свой проект под androidx, замените

implementation 'android.support.v7.widget.CardView'

на

implementation'androidx.cardview:cardview:1.0.0'
...