Created
August 6, 2014 16:57
-
-
Save j-onathan/625f5143b31ae9fae5bb to your computer and use it in GitHub Desktop.
Android Code Example: Saving app preferences (from https://www.codota.com/android/scenarios/52fcbda9da0a47f42608f550/saving-app-preferences?tag=dragonfly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onListItemClick (ListView listView, View view, int position, long id) { | |
super.onListItemClick(listView, view, position, id); | |
Editor editor = prefs.edit(); | |
editor.putInt("index", listView.getFirstVisiblePosition()); | |
editor.putInt("top", listView.getChildAt(0) == null ? 0 : listView.getChildAt(0).getTop()); | |
editor.commit(); | |
Object o = this.getListAdapter().getItem(position); | |
String testName = o.toString(); | |
Bundle bundle = new Bundle(); | |
bundle.putString("test", testName); | |
Intent intent = new Intent(this, GdxTestActivity.class); | |
intent.putExtras(bundle); | |
startActivity(intent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment