android - How to maintain the position of ListView -
possible duplicate:
maintain/save/restore scroll position when returning listview
how can maintain position of listview in activity when go activity (by launching intent) , come (press button)?
thank you.
declare global variables:
int index = 0; listview list;
and make reference listview
in oncreate()
:
list = (listview) findviewbyid(r.id.my_list);
next, in onresume()
, add line @ end:
list.setselectionfromtop(index, 0);
lastly, in onpause
, add following line end:
index = list.getfirstvisibleposition();
Comments
Post a Comment