that_person

Android: Saving App Preferences (via http://goo.gl/AYrOqp)

Aug 6th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. protected void onListItemClick (ListView listView, View view, int position, long id) {
  2.     super.onListItemClick(listView, view, position, id);
  3.  
  4.     Editor editor = prefs.edit();
  5.     editor.putInt("index", listView.getFirstVisiblePosition());
  6.     editor.putInt("top", listView.getChildAt(0) == null ? 0 : listView.getChildAt(0).getTop());
  7.     editor.commit();
  8.  
  9.     Object o = this.getListAdapter().getItem(position);
  10.     String testName = o.toString();
  11.  
  12.     Bundle bundle = new Bundle();
  13.     bundle.putString("test", testName);
  14.     Intent intent = new Intent(this, GdxTestActivity.class);
  15.     intent.putExtras(bundle);
  16.  
  17.     startActivity(intent);
  18. }
Add Comment
Please, Sign In to add comment