recyclerView is more advanced, flexible from listView. It is more easy to customize it and faster.
0. Add the library to the dependencies
- 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.
Click Ok to add the library to the dependencies.
Specify an ID
Here is the XML code
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
Click Add new resource
Click New Layout File… Specify the name, the root element and click OK
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.
Now an other Layout view and then the Views you need so you can display the information you need
And this is how it looks the recyclerView now
You can read more here.
END OF PART 1
- Android – Notifications
- Content Provider – Part 3 – insert, delete, update, getType
- Content Provider – Part 2 – create and query