为什么我的 RecyclerView 变成了灰色?有人知道吗?

huangapple go评论56阅读模式
英文:

Why is my recyclerview greyed out? Anyone?

问题

以下是您要翻译的内容:

为什么我的 RecyclerView 变成了灰色?有人知道吗?

我正在使用正确的依赖项,并且您可以看到我的 XML 布局已经正确排列,有人可以帮忙吗?

英文:

为什么我的 RecyclerView 变成了灰色?有人知道吗?

Am using the right dependencies and as you can see my xml is properly arranged, someone hep out

答案1

得分: 2

可以出现这种情况的原因有很多。

1. 依赖问题:
检查你的应用的 build.gradle 文件,查看是否已添加以下依赖。如果没有,请添加它们并重新构建项目。

如果你的项目使用 appcompat:
implementation 'com.android.support:recyclerview-v7:28.0.0'

如果你的项目使用 androidX:
implementation "androidx.recyclerview:recyclerview:1.1.0"

2. 错误的依赖:
如果上述步骤都没问题,你需要检查你的项目是否使用了 appcompat。如果是,你需要将 XML 文件中的 RecyclerView 替换为以下代码:

<android.support.v7.widget.RecyclerView
    android:id="@+id/home_recyclerview"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
英文:

That can happen due to various reasons

1. Dependency issue:
Check your app's build.gradle if you have one of the dependencies. if not, add them and rebuild the project.

If your project is in appcompat:
implementation 'com.android.support:recyclerview-v7:28.0.0'

If your project is in androidX:
implementation "androidx.recyclerview:recyclerview:1.1.0"

2. Wrong dependency:
If the above is correct, you need to check if your project is in appcompat or not, if yes, you will need to replace the recyclerview in xml file with below code:

&lt;android.support.v7.widget.RecyclerView
    android:id=&quot;@+id/home_recyclerview&quot;
    android:scrollbars=&quot;vertical&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;/&gt;

huangapple
  • 本文由 发表于 2020年8月22日 21:52:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63536939.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定