Guest User

Untitled

a guest
Nov 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. @Override
  2. public void onSaveInstanceState(Bundle outState) {
  3. super.onSaveInstanceState(outState);
  4.  
  5. View v = adslist.getChildAt(0);
  6. int index = adslist.getFirstVisiblePosition();
  7. int top = (v == null) ? 0 : v.getTop();
  8.  
  9. outState.putInt("index", index);
  10. outState.putInt("top", top);
  11. }
  12.  
  13. @Override
  14. public void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16.  
  17. if(savedInstanceState != null) {
  18. setScrollPosition(savedInstanceState);
  19. }
  20. }
  21.  
  22. public void setScrollPosition(Bundle scrollState) {
  23.  
  24. if(scrollState != null) {
  25. top = scrollState.getInt("top", 0);
  26. index = scrollState.getInt("index", -1);
  27. }
  28. }
  29.  
  30. listview.setSelectionFromTop(index, top);
Add Comment
Please, Sign In to add comment