Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS 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 18.104.22.168 release ready!
Owner and Founder. Opencart
Today we are going to learn the switching between list and grid view with data binding and recyclerview, as we have seen in many m-commerce sites.
We are going to use a static flag to check whether we have to inflate grid view or list view. The flag is intially set to list view (i.e static Boolean isGrid=false; ). You can do this by saving a value to the shared preferences.
Start by creating two xml file for two views (list and grid). You can create your own view file I had created the two as item.xml and item_grid.xml.
Now in main activity we need a view switcher we are using a imageview inside a FloatingAction Button.
And the activity will be like
Now the important part is creating adapter for both the views
And its ready. you can use any number of views but try to not make it so complicated by adding unnecessary views. So thats all about recycler view with data binding.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.