Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
RecyclerView
RecyclerView is a successor view group of ListView and GridView.It has different features from ListView and GridView which makes it powerful.In this blog we will discuss about RecyclerView and its Adapter.
Creating New Project 1. In Android Studio, go to File ⇒ New Project and fill all the details required to create a new project. When it prompts to select a default activity, select Blank Activity and proceed.
2. Open build.gradle and add recycler view dependency.com.android.support:recyclerview-v7:28.0.0 and rebuild the project.
dependencies { //…
//RecyclerView implementation ‘com.android.support:recyclerview-v7:28.0.0’
}
create view RecyclerView in activity_main.xml
The Card Layout: Card Layout is treated as an item of RecyclerView.
person_list.xml
The Data Class: The class that holds information about recyclerView
The ViewHolder: ViewHolder holds information about card layout .
The Adapter: It is responsible for inflating the view and view holder ,binding data to view . It extends RecyclerView.Adapter .There are three main method of RecyclerView.Adapter which are necessary to override
1.onCreateViewHolder: This method only called when new view created. If views are recycled then there is no need to create new view.
2.onBindViewHolder:It sets data to particular items of the RecyclerView.It called every time when it scrolled
3.getItemCount: which Returns the length of the RecyclerView.
LayoutManagers
We use LayoutManager class for specifying position of recyclerView’s item.There are three ways of displaying RecyclerView data.
LinearLayoutManager
GridLayoutManager
StaggeredGridLayoutManager
Set Adapter to RecyclerView
we need to set adapter to recyclerView which we created . we pass list in constructor of MyAdapter
recyclerView.setAdapter(new MyAdapter(list));
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.
Hussein Zawia
Co-founder, 24Dokan
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.