关于android:cannot resolve RecyclerView Adapter

cannot resolve RecyclerView Adapter

我正在学习本教程,我需要添加 recycleview。但 Android Studio 无法解析 RecyclerView。我也向 gradle 文件添加了依赖项。我尝试将库添加到 lib 文件夹,如此处所述。但没有任何效果。

1
compile 'com.android.support:recyclerview-v7:23.2.0'

enter

1
2
3
4
5
6
7
8
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'

}

在这一行失败了。

1
2
3
4
RecyclerView.Adapter recyclerViewAdapter;

recyclerViewAdapter = new RecyclerViewAdapter(navTitles,navIcons,this);
recyclerView.setAdapter(recyclerViewAdapter);


您只需要进一步阅读本教程,其中包含 RecyclerViewAdapter 类(扩展 RecyclerView.Adapter)的定义。