Android using onConfigurationChanged resets my listview scroll position -


in app have chat activity listview. decided use onconfigurationchanged retain listview messages, while user changes screen orientation. problem scroll position resetting every time. how can keep scroll position listview. in manifest

<activity             android:name=".chatactivity"             android:configchanges="keyboardhidden|orientation|screensize" /> 

in activity

@override     public void onconfigurationchanged(android.content.res.configuration newconfig) {         super.onconfigurationchanged(newconfig);         log.d(tag, "orientation changed");         chatview.setselection(scrollposition);     } 

remove this:

chatview.setselection(scrollposition); 

[edit]

//save state parcelable state = listview.onsaveinstancestate();  //restore state listview.onrestoreinstancestate(state); 

[edit2]:

//save int index = mlist.getfirstvisibleposition(); view v = listview.getchildat(0); int top = (v == null) ? 0 : (v.gettop() - mlist.getpaddingtop());  //restore listview.setselectionfromtop(index, top); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -