美文网首页
Android Studio 3.5+ 使用androidx的r

Android Studio 3.5+ 使用androidx的r

作者: 明早天气不错 | 来源:发表于2019-10-21 18:26 被阅读0次

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,在括号里面输入上述文字。修改布局文件如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView

        android:id="@+id/recycler_view"

        android:layout_width="match_parent"

        android:layout_height="match_parent"/>

</LinearLayout>

然后就可以使用了

相关文章

网友评论

      本文标题:Android Studio 3.5+ 使用androidx的r

      本文链接:https://www.haomeiwen.com/subject/wiqxvctx.html