0

I want to add multiple array-list in a list and display in list-view using custom adapter with section. i have tried here is my code i tried

   for (int i=0;i<mModelJsoncatData.size();i++){
                if (mModelJsoncatData.get(i).getCatName().equals("Eating")) {
                    ListAll.add(new String(mModelJsoncatData.get(i).getCatName()));
                    ListAll.addAll(mModelJsonEating);
                }
                if (mModelJsoncatData.get(i).getCatName().equals("Feeling")) {
                    ListAll.add(new String(mModelJsoncatData.get(i).getCatName()));
                    ListAll.addAll(mModelJsonFeeling);
                }
                if (mModelJsoncatData.get(i).getCatName().equals("Listening to")) {
                    ListAll.add(new String(mModelJsoncatData.get(i).getCatName()));
                    ListAll.addAll(mModelJsonListening);
                }
                if (mModelJsoncatData.get(i).getCatName().equals("Watching")) {
                    ListAll.add(new String(mModelJsoncatData.get(i).getCatName()));
                    ListAll.addAll(mModelJsonWatching);
                }
            }
MAdapter adapter=new MAdapter(this,ListAll);
listview1.setAdapter(adapter); 

but its not showing the desired results any suggestions or help needed

Noman Malik
  • 103
  • 3
  • 5
  • 18

1 Answers1

0

What you want is a list of lists!

List<List<Integer>> lists = new ArrayList<List<Integer>>();
for (int i = 0; i < 4; i++) {
    List<Integer> list = new ArrayList<>();
    lists.add(list);
    // Use the list further...
}

To Merge 3 arraylist to one

List<String> combined = new ArrayList<String>();
combined.addAll(firstArrayList);
combined.addAll(secondArrayList);
combined.addAll(thirdArrayList);

Reference :-https://stackoverflow.com/a/8625256/7795876

Community
  • 1
  • 1
Saurav Prakash
  • 588
  • 1
  • 5
  • 26