RecyclerView在android(androidx)中的依赖关系?

问题描述 投票:0回答:3

我使用了 RecycleView 的实现

'com.google.android.material:material:1.0.0'
。在布局中,当我输入“回收”时,它给出的建议为
androidx.appcompat.app.AlertController$RecycleListView
,这不是我想要的。

即使我输入这个

androidx.recyclerview.widget.RecyclerView
,它也能工作,但它不允许使用诸如 id、高度、宽度等属性。一个月前它工作得很好,就像它给出了正确的建议一样,现在它完全没有在 RecycleView 中显示。有没有人有解决办法?

android android-recyclerview
3个回答
4
投票
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'

更新

这是我的

build.gradle
中一些库的列表:

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

另请参阅支持库中的RecyclerView在哪里?如何导入适用于Android L-preview的RecyclerView


2
投票
  • 首先删除与

    RecyclerView
    相关的所有依赖项,然后转到 XML,然后切换到设计。您将看到带有下载箭头的
    RecyclerView
    。单击该箭头。

  • 这将根据您的 SDK 版本添加依赖项。无需为此添加特定版本。这将自行完成。


0
投票
 1.Open build.gradle and add recycler view dependency. 

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1' 

2. left corner of this file sync now option and click on it.

3. in xml file you can add below code:

<androidx.recyclerview.widget.RecyclerView
 android:id="@+id/listing"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />
© www.soinside.com 2019 - 2024. All rights reserved.