Introduction

In this lecture we will describe about how can we create RecyclerView in Material Design ,and also describe what is RecyclerView. Why we use it. After reading this lecture you will also able Understand RecyclerView and also create Recyclerview of your application.

Prerequisite

If you not understand this lecture. RecyclerView in Material Design.You should also read my previous lectures How to Create Project – Material design and Toolbar in Android Material design .These lecture are interrelate of each other.

RecyclerView

Google has introduced visual component to enhance the application development.The new interface is material design.Which consists of RecyclerView and CardView. But These component are available in android Lollipop API . RecyclerView is more advance version of list view and Recycler view is more flexible as compare to list view. Recycler view is used when list that is to be changed dynamically. For more detail about how you create RecyclerView in material design click on RecyclerView in material design.

Objectives

  • How to add RecyclerView in your app
  • How to run the app in your Emulator

Tools & Envirvement

  • Android Studio    5.0
  • Minimum SDK    API 19 Android 4.4 (Kitkat)
  • Target SDK      API 21 Android 5.0 (lollipop)

SDK Manager

Check that SDK-Tool Platefrom-Tool and Built-Tool are installed.

Alt Tag Recycler view in material design sdk image

RecyclerView in Material design

Implementation Section

  1. RecyclerView Architecture
  2. RecyclerView set Adpter
  3. RecyclerView Displaying Data

RecyclerView Architecture

Alt Tag RecyclerView in material design

 

First you will open a “build.Gradle file” and add this library  “compile com.android.support:recyclerview-v7:21.+” in inside the dependencies. In my case target SDK is 21 So we will use targetSdkVersion 21, and rebuild the project.

After that click on layout folder, then select Fragement_navigation_Drawer layout, then change into Relative layout, add this library “android.support.v7.widget.RecyclerView” into layout. After that set the height and width.

Write the following code Fragement_navigation_Drawer layout. XML file

  • In this example we are going to create a simple UI that includes only (Text  view)  with Different attributes.
Step 1=<- create a new Class  infomation ><-Right click-><-Package name->Select <-New ->then you click on<-javaClass- >< that are show in below pic.

Alt Tag RecyclerView in material design

Step2=Step1<-WriteName->Ok.

Alt Tag recyclerView in material design

After complete this step you will open a “Information.java” Class file and write the following code.

  • Step 4=<- create a new name custom_row->Right click> the ->layout folder-> select ->New option-> and click>layout resource folder->
  •  Step5=Step4->WriteName->Ok
  • In this example we are going to create a simple UI that includes only (Text  view)and(ImageView)  with Different attributes.And Write the following code into Custom_row.XML file

Step 6=<- create a new Class  ViewAdpter ><-Right click-><-Package name->Select <-New ->then you click on<-javaClass- >< that are show below.

  • Step7=Step6->WriteName->Ok.
  • If you do not understand this please read first step1.

After completing this step you will open a ViewAdpter.java Class file and write the following code.

After completing this step you will open NavigationDrawerActiviyt.java Class file and write the following code.

 Run the Application

Alt Tag recyclerview in material design output image

Conclusion

In this lecture we learned about RecyclerView in material  design. First we learned about how  can you create a  RecyclerView. Description of architecture of recylcerView in material design. I hope you will understand this lecture. Thank you for reading this lecture Hope you got the idea.

 

 

  • Mario German Agudelo

    Hi, thanks for sharing your knowledge: I have an application which has two buttons on the main activity, the idea is that by giving click on them, I send activity recyclerview which would be the same for the two buttons, the only thing is that by giving click button 1 to display information only on that button and the button 2 to give click to show only the information that button, I appreciate all the information you can give me, thank you.