简体   繁体   English

扩展RecyclerView.Adapter不可用

[英]extends RecyclerView.Adapter not available

trying extend my class with "extends RecycleView.Adapter" but it seams like it is not "available" , I Rebuilded and cleaned up the project but it's no help. 尝试使用“ extends RecycleView.Adapter”扩展我的类,但它看起来像是“不可用”,我重新生成并清理了该项目,但没有帮助。 build.cradle : (in case that have anything to do with it) build.cradle :(如果与它有任何关系)

 minSdkVersion 15
 targetSdkVersion 23
 compileSdkVersion 23
 buildToolsVersion "23.0.1" 

(thank U for any help) (感谢您的帮助)

You have to import its library as follows : 您必须按以下方式导入其库:

compile 'com.android.support:recyclerview-v7:23.0.1'

Example : 范例:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:23.0.1'
}

Make sure that you are importing import android.support.v7.widget.RecyclerView; 确保您要导入import android.support.v7.widget.RecyclerView;

Your class should look like this : 您的课程应如下所示:

public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.CustomViewHolder> {

Had the same issue where I could not extend RecyclerView.Adapter and it was that I copied and pasted the following: 在无法扩展RecyclerView.Adapter的问题相同,是我复制并粘贴了以下内容:

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'

but I should have replaced the :appcompat with :recyclerview 但我应该用:recyclerview替换:appcompat

Here is the correct lines in the dependencies section of the gradle script build.gradle: 这是gradle脚本build.gradle的dependencies部分中的正确行:

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.4.0'

Hope this helps someone wondering why they could not extend RecyclerView.Adapter 希望这有助于某人想知道为什么他们不能扩展RecyclerView.Adapter

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

相关问题 扩展 Recyclerview.Adapter 与 RecyclerView.Adapter 有什么区别<subclassrecyclerviewadapter.viewholder>在回收站视图中</subclassrecyclerviewadapter.viewholder> - what is the difference between extends Recyclerview.Adapter vs RecyclerView.Adapter<SubclassRecyclerViewAdapter.ViewHolder> in RecyclerView 无法在我的类中使用 onBindViewHolder 实现 extends RecyclerView.Adapter - cannot implements with the onBindViewHolder in my class extends RecyclerView.Adapter 如何在扩展RecyclerView.Adapter的类中重新绑定视图 - How to rebind view in a class that extends RecyclerView.Adapter 从 RecyclerViewAdapter 启动BottomSheet,它在onBindViewHolder 内扩展了RecyclerView.Adapter - Launching BottomSheet from a RecyclerViewAdapter that extends with RecyclerView.Adapter inside onBindViewHolder RecyclerView.Adapter onClick - RecyclerView.Adapter onClick 更新RecyclerView.Adapter - Update RecyclerView.Adapter RecyclerView.Adapter的上下文 - Context for RecyclerView.Adapter 无法将自定义添加的方法调用到我的适配器中(扩展 RecyclerView.Adapter<MyAdapter.ViewHolder> ) - Cant call a custom added method into my adapter (extends RecyclerView.Adapter<MyAdapter.ViewHolder>) RecyclerView.Adapter不需要的空间 - RecyclerView.Adapter Unwanted Space Android RecyclerView.Adapter的泛型 - Generics for RecyclerView.Adapter Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM