-1

私はアンドロイド開発が初めてです。メール アクティビティでリサイクラー ビューを作成しています。

アクティビティのレイアウトを次のように定義しました。

<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'
}

私が間違っていることを教えてください。また、さらに情報を追加する必要がある場合はお知らせください。

4

2 に答える 2

1

これを使って:

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'
}

バージョンの異なる複数のライブラリがあります。

于 2015-11-21T18:47:01.160 に答える
0

onCreate()を呼び出した後、 でこれを行うことができますsetContentView(...)

rv = (RecyclerView) findViewById(R.id.recycler_view);
于 2015-11-21T18:53:07.357 に答える