简体   繁体   English

如果没有它,我应该将 RecyclerView 依赖项添加到 gradle 吗?

[英]Should I add RecyclerView dependency to gradle if it works without it?

I have some android projects, where I use often use RecyclerView(if it matters, it's the widget with androidx prefix) without adding any dependencies.我有一些 android 项目,我经常使用 RecyclerView(如果重要的话,它是带有 androidx 前缀的小部件)而不添加任何依赖项。 But when I look gradle-files of another projects(even which developed by Google), I see this dependency:但是当我查看另一个项目的 gradle-files(甚至是由 Google 开发的)时,我看到了这种依赖关系:

implementation "androidx.recyclerview:recyclerview:$recycler_view_version"

So, I have questions.所以,我有问题。

  1. Should I add it to my gradle if I don't have any problems with RecyclerView?如果我对 RecyclerView 没有任何问题,是否应该将其添加到我的 gradle 中?
  2. Maybe is there another dependency, which includes RecyclerView as well?也许还有另一个依赖项,其中也包括 RecyclerView ?

It seems that you have created your project in androix.看来您已经在 android 中创建了项目。

Material dependency:-材料依赖性:-

implementation 'com.google.android.material:material:1.2.1'

Basically material dependency contains all the widgets implementation.基本上材料依赖包含所有的小部件实现。 So you can access those widgets directly after injecting this dependency.因此,您可以在注入此依赖项后直接访问这些小部件。

It may be possible that you have added material dependency in your gradle.您可能在 gradle 中添加了材料依赖性。 so after injection of material dependency no need to inject separate recyclerview's dependency.所以在注入材料依赖后不需要注入单独的recyclerview的依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM