How to add the recyclerview to project

后端 未结 5 1264
栀梦
栀梦 2021-02-19 03:21

tried to import android.support.v7.widget.RecyclerView, but it didn\'t work, added also

compile \'com.android.support:recyclerview-v7:23.1.1\'

相关标签:
5条回答
  • 2021-02-19 03:49

    Only putting this

    implementation'com.android.support:design:25.3.1'
    

    Will also work.

    0 讨论(0)
  • 2021-02-19 03:50

    you can also add lib/dependencies from android studio menu.

    click on "Build" -> "Edit Libraries and Dependencies". then click on "+" button on right side.

    search any lib.

    example search "recycler"

    then select "com.android.support:recyclerview-v7:x.x.x" from list and your done.

    0 讨论(0)
  • 2021-02-19 03:55
    1. Open build.gradle and add recycler view dependency. com.android.support:recyclerview-v7:23.1.1 and rebuild the project.

    build.gradle

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'}
    
    1. With the latest version of build tools, Android Studio is creating two layout files for each activity. For main activity, it created activity_main.xml (contains CoordinatorLayout and AppBarLayout) and content_main.xml (for the actual content). Open content_main.xml and the recycler view widget.

    Layout

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical" />
    
    </RelativeLayout>
    
    0 讨论(0)
  • 2021-02-19 03:59

    build gradle:

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

    xml file:

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    
    0 讨论(0)
  • 2021-02-19 04:11

    Update this Dependency Latest

    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    
    0 讨论(0)
提交回复
热议问题