c# - How to Split a List into two to populate differnt listviews? -
i have list gets populated api want split list 2 can populate 2 different listview on same screen how can this?
items = new list<tableitem> (); items.add (new tableitem (){ subprofilename = "apple" }); items.add (new tableitem (){ subprofilename = "pear" }); items.add (new tableitem (){ subprofilename = "shoe" }); items.add (new tableitem (){ subprofilename = "cake" }); items.add (new tableitem (){ subprofilename = "vodka" }); items.add (new tableitem (){ subprofilename = "alize" }); ....... ....... ....... listview = findviewbyid<listview>(resource.id.listviewforsubprofiles); listview.adapter = new selectprofileadapter(this, items);
you can use getrange() method part of list, in example need know how many items want in each group split them properly, let's have 10 items , want put 5 in each listview, can this:
list<tableitem> firstlist = items.getrange(0, 5); list<tableitem> secondlist = items.getrange(5, 5);
if want jump ahead, can list when set adapter:
listview.adapter = new selectprofileadapter(this, items.getrange(startindex, numitems));