0

I want to add two list in a single List View. Both with different adapter.

i just found this one but i want something else

how can set two adapter into a list?

i want my list View like this one

enter image description here

is it possible..

Community
  • 1
  • 1
Mayur Kharche
  • 717
  • 1
  • 8
  • 27

1 Answers1

1

U need to override getItemViewType and getViewTypeCount.

@Override
public int getViewTypeCount() {
   return 2;
}

@Override
public int getItemViewType(int position) {
   int type=0;
   if(getItem(position).isFolder())
     type=1;
   else{
     type=2;
   }
}

And than u inflate your xml files for 2 items. Please review this link.

Add headers in a listView using ArrayAdapter

And also u create common model include to two items.

public class CommonModel
{
   private FolderItem folderItem;
   private RadioItem radioItem;
   //getter and setter
}

For example if myList.get(position).getFolderItem equals null u return song item type and inflate your song view.

Community
  • 1
  • 1
user3307005
  • 216
  • 4
  • 12
  • But this one is using only one adapter in it i want to use two adapters. – Mayur Kharche Aug 23 '15 at 05:08
  • I dont undestand exactly why are u need to two adapter ? I think u should use single adapter and your adapter's model include two item type. I update my answer for add to simple model. – user3307005 Aug 23 '15 at 20:05
  • I too have the same problem @user3307005 I have some values hard coded in my array adaptor and to that I want to add values from my firebaselistadaptor which is another adaptor and display them in one Lakeview..how can I do that? – Char Oct 20 '17 at 03:38