Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- View v = adslist.getChildAt(0);
- int index = adslist.getFirstVisiblePosition();
- int top = (v == null) ? 0 : v.getTop();
- outState.putInt("index", index);
- outState.putInt("top", top);
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if(savedInstanceState != null) {
- setScrollPosition(savedInstanceState);
- }
- }
- public void setScrollPosition(Bundle scrollState) {
- if(scrollState != null) {
- top = scrollState.getInt("top", 0);
- index = scrollState.getInt("index", -1);
- }
- }
- listview.setSelectionFromTop(index, top);
Add Comment
Please, Sign In to add comment