【问题标题】:RecyclerView dependencies in android(androidx)?android(androidx)中的RecyclerView依赖项?
【发布时间】:2019-11-11 08:59:14
【问题描述】:

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

即使我正在输入这个androidx.recyclerview.widget.RecyclerView,它也可以工作,但它不会让使用的属性如 id、height、width 等在里面。一个月前它工作得很好,就像它现在给出了正确的建议一样,它完全没有显示给 RecycleView。有人有解决办法吗?

【问题讨论】:

    标签: android android-recyclerview


    【解决方案1】:
    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'
    

    另见Where is the RecyclerView in the support library?How to import RecyclerView for Android L-preview

    【讨论】:

    • 不,它仍然给我建议“androidx.appcompat.app.AlertController$RecycleListView”..还有其他解决方案吗?
    • @IRONMAN,请出示您的build.gradle 和错误信息。
    • see..我没有收到错误好的...我已经在我的 Gradle 中添加了您的依赖项,但它没有给我在 xml 中回收视图的正确建议...它给了我一些东西比如“androidx.appcompat.app.AlertController$RecycleListView”
    • @IRONMAN,我添加了一张图片。
    • 感谢您接受分析器,朋友@AshwiniJ。
    【解决方案2】:
    • 首先删除与RecyclerView 相关的所有依赖项,然后转到您的XML,然后切换到设计。您将看到带有下载箭头的RecyclerView。点击那个箭头。

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

    【讨论】:

    • 乐于助人!!
    猜你喜欢
    • 2021-08-29
    • 2019-07-10
    • 1970-01-01
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 2023-02-19
    • 2020-02-28
    • 1970-01-01
    相关资源
    最近更新 更多