Android: What’s the best way to implement the BaseAdapter if item content in ListView is dynamic? -


in case, need implement baseadapter’s getitemviewtype() , getviewtypecount() dynamic item content of listview, this post says. think solution suitable finite number , knowing beforehand, such listview item sending layout , receving layout.

what case listview item content impossible knowing beforehand? example, need show contact list server, contact list size several thousand. each item, need show, example, hobby “list”. small range of 0 tens of string. in case:

  1. the item types relatively bigger normal case using “getitemviewtype”
  2. though each item may different, similar degree: item content different in number of views, common in view type. item different item b because have more textviews.

enter image description here

for each time in getview, convertview hard reuse because different, if create new textview , added convertview, impact scrolling of listview. don't think it's appropriate such way. should in such case?

unfortunately cannot change number of item view types on fly. getviewtypecount() method invoked when adapter set on listview. means, dynamically change it, have call setadapter() again. huge performance hit listview toss out recycled views , re-generate scratch again.

honestly, looks should using expandablelistview instead. allows displays lists of items under groups. difference groups placed on top of list. have a, b, c, d on left side in picture...in expandablelistview it'll sit on top.

the expandablelistview can handle situation given grouping have variable number of items within it. mentioned needing store contact list. i'd suggest taking @ rolodexarrayadapter use expandablelistview. may of help.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -