Whether or not to use multiple instances of an Activity on Android? -


if have app refills listview different data in response user selecting item. should start new activity or change data, , call adapter.notifydatasetchanged()?

it seems calling notifydatasetchanged() simpler, , minimize potential number of activities (and memory usage), want up/back navigation work.

my app works file explorer there list of folders, , clicking on folder changes list show contents of new folder. if user clicks on folder, want up/back buttons take them prior folder. have implemented single instance of activity , using notifydatasetchanged(), can't up/back buttons working desired. thinking need either override somehow, or use multiple instances of same activity. direction here appreciated.

thanks

using multiple instances of same activity highly unproductive.

to solve problem, best way use fragment using multiple instances of it, each 1 representing folder in arborescence. in onbackpressed() of activity, can use popbackstack() while there fragment in backstack, call super.onbackpressed() resume default behavior.



Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -