Android Studio 3.5+ 使用androidx的recyclerView

Android逐渐淘汰support之前的版本,Android studio 导入support.v7也会出错。

在Android developers中找到了添加依赖项的方法:

dependencies {

def recyclerview_version = "1.0.0"

implementation "androidx.recyclerview:recyclerview:$recyclerview_version"

// For control over item selection of both touch and mouse driven selection

implementation "androidx.recyclerview:recyclerview-selection:$recyclerview_version"

}

在build.gradle(Module:app)中找到dependencies,在括号里面输入上述文字。修改布局文件如下:


    android:layout_width="match_parent"

    android:layout_height="match_parent">

   

        android:id="@+id/recycler_view"

        android:layout_width="match_parent"

        android:layout_height="match_parent"/>

然后就可以使用了

你可能感兴趣的:(Android Studio 3.5+ 使用androidx的recyclerView)