
Open adle and add recycler view dependency. When it prompts to select a default activity, select Blank Activity and proceed.Ģ. In Android Studio, go to File ⇒ New Project and fill all the details required to create a new project. Currently my Android Studio is updated to Android Studio 2.0 Preview 6.ġ. īefore you start, make sure that you updated your Android Studio to latest version.

The recycler view we are going to design contains list of movies displaying the title, genre and year of release.īelow is the RecyclerView widget with necessary attributes. We’ll also learn writing a adapter class, adding list divider and row click listener. In this tutorial we are going to learn how to render a simple RecyclerView with a custom layout.

Here is the complete information about RecyclerView and other examples. Using RecyclerView and CardView together, both lists and grids can be created very easily. Public class ItemArrayAdapter extends RecyclerView.Android RecyclerView is more advanced version of ListView with improved performance and other benefits. This adapter is also a very simple and contains only the minium required methods, constructor and ViewHolder. ItemArrayAdapter.java, this is the adapter for the RecyclerView. For demonstration purpose, this class is very simple, only have one field, the name.

Item.java, the item class for each item in the list, it can be any other custom class. List_item.xml, layout file for each of the row in the RecyclerView. You can replace the default generated code with the following.

It will display a list of TextViews with item number, when an row is clicked, a log message will be printed with the item number of the view that’s clicked.Īdd the RecyclerView support library in your gradle dependenciesĬompile ':recyclerview-v7:23.1.0'Īctivity_main.xml, layout file for the main activity which will hold the RecyclerView in this example. In this post, we will create a basic item list using RecyclerView and implementing the View.OnClickListener.
