java - ListView feeded with more adapters acording to need -


i'm pretty new in android coding. have simple app there is, amongst other views, listview.

now, when 'bystanding' button clicked, need listview change it's content... there actualy 3 modes in listview can be, thinking how change content(the user can change many times instantly mode wants) best way.

i know can rewrite data of adapter , call 'notifydatasetchanged', think me it's better create several adapters , attach them listview whenever want... possible? i've tried , doesn't work how want:

the first mode chosen when app oncreates has 7 items. second ones have each 2 different items. have done calling 'setadapter' method , happened there 2 of previous(seven-itemed) adapter.

even when write @ end

listview.invalidate(); adapter.notifydatasetchanged(); 

hope understand i'm trying say. ok attach adapter when want? shall change data of one? please help.

is ok attach adapter when want?

           maintaining multiple instances of adapter single listview not idea.
instead of maintaining multiple adapter instances, maintain single instance of adapter , update data in adapter using

adapter.notifydatasetchanged(); 

Comments