Android – recyclerView PART 1

recyclerView is more advanced, flexible from listView. It is more easy to customize it and faster.

Implementation

0. Add the library to the dependencies

implementation 'com.android.support:recyclerview-v7:28.0.0'
  1. Add recyclerView to the XML layout file

Select Container and drag and drop the RecyclerView to the Component Tree or to the Design Layout. If you see this below, click the icon at the right.

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Click Ok to add the library to the dependencies.

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ
Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ
Design Layout

Specify an ID

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Here is the XML code

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

2. Create an item Layout

You can create the file yourself or click on the dots at the right of the listitem and this way will update the items in the recyclerView

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Click Add new resource

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Click New Layout File… Specify the name, the root element and click OK

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Now you can choose the view you want to add for each item in the recyclerview. Height of all view must be wrap-content. The first view I chose is CardView. This should be added in the dependencies too. You should specify ID, cardBackgroundColor, cardCornerRadius, contentPadding, cardElevation and click on cardUseCompatPadding.

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

Now an other Layout view and then the Views you need so you can display the information you need

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ
Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ
Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

And this is how it looks the recyclerView now

Implement recyclerview, <span>Android – recyclerView PART 1</span>, KandZ

You can read more here.

END OF PART 1

96350cookie-checkAndroid – recyclerView PART 1Android – recyclerView PART 1

Related posts

3 Thoughts to “Android – recyclerView PART 1

  1. […] Android – recyclerView PART 1 […]

Comments are closed.