android - highlight previous selected item when user come back from another activity -
activity1
has listview
. clicking 1 item (let's item 3) start activity2
. activity2
have button once clicked bring user activity1
. want achieve highlight item 3 when user activity1
user have sense continue. (may need set focus item 3 well.)
edit: following code works.
public void onresume() { super.onresume(); //lastselectedposition saved in onitemclicklistener lv.setselection(lastselectedposition); lv.requestfocusfromtouch(); }
well pretty simple. save clicked item position of list field when list clicked launch new activity.
afterwards in onresume() method use mylist.setselection(savedposition);
as highlighting, focus works kinda bad if have bit more complex rows(buttons,checkboxes etc) , other ui elements beside list can take away focus. believe best way achieve set background of particullar item onresume highlighted 1 , override onscroll listener change background default when list scrolled. indeed workaround work in 100% of cases opposite focusing item. plus maybe can add animations on view can make nice , smooth.
Comments
Post a Comment