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
Expandable Recycler view is alternative of ExpandableListView. There are many times when ExapandableListView don’t perform as per the requirement. It fails in the coordinator layout as well as have layout height issue.
Thus we are creating a simple Expandable Recycle view using bignerdranch’s expandablerecyclerview library.
Dependency used in this blog:
compile ‘com.bignerdranch.android:expandablerecyclerview:2.1.1’
SubcategoryParentListItem is our parent class that is used to store the data relevant to parent.
SubcategoryChildListItem is our simple child class used to display the content in each child of parent
Creating List of parent item to be displayed in a view.
Creating a list of child item and setting this list to a particular parent.
subcategoryParentListItem.setChildItemList(childItemList); // set the list of child item for a parent item.
Unlike traditional Recycler view in which we have a single view holder and thus single onCreateViewHolder and onBindViewHolder, We have two different sets of onCreateViewHolder and onBindViewHolder.
That’s all folks. Stay updated !
REFERENCE: https://github.com/bignerdranch/expandable-recycler-view
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.
Thanks in advance
childViewHolder.txtListChild.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // your logic here } });
private List getGroups(){ List reminderList = RealmReminders.getReminderList(mActivity, 0); List todayReminder = new ArrayList(); List tomorrowReminder = new ArrayList(); List otherDayReminder = new ArrayList();
for (MyReminder thisReminder : reminderList){ if (thisReminder.getRemindDay() == mThisDay) todayReminder.add(thisReminder); else if (thisReminder.getRemindDay() == mThisDay+1) tomorrowReminder.add(thisReminder); else if (thisReminder.getRemindDay() > mThisDay+1) otherDayReminder.add(thisReminder); }
List list = new ArrayList(); ReminderGroup today, tomorrow, otherDay; if (todayReminder.size() != 0) { today = new ReminderGroup(“Today”, todayReminder); list.add(today); } if (tomorrowReminder.size() != 0) { tomorrow = new ReminderGroup(“Tomorrow”, tomorrowReminder); list.add(tomorrow); } if (otherDayReminder.size() != 0) { otherDay = new ReminderGroup(“Next”, otherDayReminder); list.add(otherDay); } return list; }
@Override public void onBindParentViewHolder(MyParentViewHolder parentViewHolder, int position, ParentListItem parentListItem) { ReminderGroup reminderGroup = (ReminderGroup) parentListItem; parentViewHolder.day.setText(reminderGroup.getDay()); }
@Override public void onBindChildViewHolder(MyChildViewHolder childViewHolder, int position, Object childListItem) { MyReminder reminder = (MyReminder) childListItem; etc }
java.lang.IllegalStateException: Null object added at com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter.getItemViewType(ExpandableRecyclerAdapter.java:223)
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
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Osama
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.