I am working on project, where I need Expandable RecyclerView. I did everything, but have some problem with "child" (rows) of every "parent".
Here is my code for "parents". First item on recycle view will be "Option 1", second "Option 2", and so on.
public TitleCreator(Context context) {
_titleParents = new ArrayList<>();
TitleParent title = new TitleParent(String.format("Option 1"));
_titleParents.add(title);
TitleParent title1 = new TitleParent(String.format("Option 2"));
_titleParents.add(title1);
TitleParent title2 = new TitleParent(String.format("Option 3"));
_titleParents.add(title2);
TitleParent title3 = new TitleParent(String.format("Option 4"));
_titleParents.add(title3);
TitleParent title4 = new TitleParent(String.format("Option 5"));
_titleParents.add(title4);
}
It works perfectly, but when I want to do same thing for child of every parent I had a problem. In the end I write in MainActivity some code to make every child of each parent the same. Here is the code:
private List<ParentObject> initData() {
TitleCreator titleCreator = TitleCreator.get(this);
List<TitleParent> titles = titleCreator.getAll();
List<ParentObject> parentObject = new ArrayList<>();
for(TitleParent title:titles)
{
List<Object> childList = new ArrayList<>();
childList.add(new TitleChild("Combe","Send message"));
title.setChildObjectList(childList);
parentObject.add(title);
}
return parentObject;
}
I need different child/row for each parent, how to do that?