Android Recyclerview with custom adapter - Tutorial

The Recyclerview widget was introduced in Android Support Library package and it is a more advanced and flexible version of ListView.
 
Aug. 2, 2015 - PRLog -- Visit our website to get the full tutorial and download source code : http://androidgifts.com/android-recyclerview-with-custom-adapter-tutorial/

Android Recyclerview with custom adapter
The Recyclerview (https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html) widget was introduced in Android Support Library package (http://developer.android.com/tools/support-library/index.html) and it is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. In this tutorial we will make Android Recyclerview with custom adapter app that would display a list of Movies which has a title, rating and an image in a recyclerview, also we’ll implement RecyclerView.OnItemTouchListener to add touch event to every single row in the recyclerview.

To make it works, you need to set a LayoutManager, a java class representing the data model and an adapter to link between them.

1. Creating Android Project, In Android Studio, create a new project by navigating to File ⇒ New Projectand fill all the required details. When it prompts to select a default activity, select Blank Activity and proceed.

2. We need to add the Android Support Library package, to do that open build.gradle located under app folder and add Android Support Library dependency.

open MainActivity.java and do the below changes to achieve the Android Recyclerview with custom adapter.

Instantiate and get a reference of the recyclerview we put in activity_main.xml and setLayoutManager for this recyclerview
Instantiate our custom adapter and make an array of Movie objects
Make a class RecyclerTouchListener which implements RecyclerView.OnItemTouchListener
Download images used in the demo from here (http://www.androidgifts.com/downloads/drawables.zip), extract the .zip file Under res

Contact
Android Gifts
***@androidgifts.com
End
Source: » Follow
Email:***@androidgifts.com Email Verified
Tags:Recyclerview, Support Library, Android, Material Design
Industry:Computers, Software
Location:India
Subject:Websites
Account Email Address Verified     Account Phone Number Verified     Disclaimer     Report Abuse
Android Gifts News
Trending
Most Viewed
Daily News



Like PRLog?
9K2K1K
Click to Share