How to add recyclerview to a project

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

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

to build .gradle but that didn't help

+7
java android android-recyclerview
source share
4 answers

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

Click CreateEdit Libraries and Dependencies . then click the “ + ” button on the right side.

find any lib.

search example "recycler"

then select " com.android.support:recyclerview-v7:xxx " from the list and done.

+19
source share
  • Open build.gradle and add a 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. Using the latest build tools, Android Studio creates two layout files for each activity. For the main activity, he created activity_main.xml (contains CoordinatorLayout and AppBarLayout) and content_main.xml (for the actual content). Open content_main.xml and the 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> 
+4
source share

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"/> 
+1
source share

Update latest dependency

 compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:design:25.3.1' 
0
source share

All Articles