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:
- the item types relatively bigger normal case using “getitemviewtype”
- 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.
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
Post a Comment