Simplifying RecyclerView step by step
1- Put <RecyclerView/> in xml you want
2- Make resource file // put design for item
3- Create class that contained data you want in every item in recycler view
4- Make Recycler Adapter class to link (RecyclerView with arrayList in main activity)
-then define array List of type Item. " item" :is the class we did
-and generate constructor “ constructor mission is to pass arrayList to RecyclerAdapter object in main method as argument”
5- Make view Holder class inside adapter class
-define variable for every element in resoursefile.xml
-generate constructor to find every element by ID from resoursefile.xml
6- inside Recycler Adapter class .OnCreateHolderMethod this method mission to inflate adapter with resource file.xml
7- inside Recycler Adapter class .OnBindViewHolderMethod….make variable to store data selected from list then pass this variable to TextView or ImageView …etc. from Holder class “that pass data in the class into resource file
领英推荐
8- inside Recycler Adapter class .GetItemcountMethod “put list size into it
In Main Activity
1-define array List
-add what you want to array list
2-then define recycler View // outside oncreate method then inside oncreate Method and find it by id
3-set Adapter
-make object from adapter class then pass array list to it as argument
-Make recyclerView.layoutManager to define orientation
- setlayoutManager
- setItemAnimater
- setAdapter
Ex: