找不到 RecyclerView

Could not find RecyclerView

我是 android 开发新手。我正在我的邮件中创建回收站视图 activity。

我已将 activity 布局定义为:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
....

</android.support.design.widget.CoordinatorLayout>

在 MainActivity.java 中,当我创建 RecyclerView 实例时,它无法解析回收器视图。

   private RecyclerView rv;

应用 gradle 看起来像:

compileSdkVersion 23
buildToolsVersion "23.0.1"
minSdkVersion 16
targetSdkVersion 23

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:design:23.1.0'
}

请告诉我我做错了什么。如果我需要添加更多信息,也请告诉我。

使用这个:

compileSdkVersion 23
buildToolsVersion "23.0.1"
minSdkVersion 16
targetSdkVersion 23

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
}

您有多个不同版本的库。

你可能想在你的 onCreate() 中执行此操作,在你调用 setContentView(...):

之后
rv = (RecyclerView) findViewById(R.id.recycler_view);