Skip to content

Instantly share code, notes, and snippets.

@noaht11
Last active August 29, 2015 14:27
Show Gist options
  • Save noaht11/abdabc2f7f276bcaffcb to your computer and use it in GitHub Desktop.
Save noaht11/abdabc2f7f276bcaffcb to your computer and use it in GitHub Desktop.
Saving state for a ListView
private static final String STATE_ITEMS = "items";
// Make sure to declare as ArrayList so it's Serializable
private ArrayList<Item> mItems;
...
@Override
protected void onSaveInstanceState(Bundle outState) {
// Make sure to call the super method so that the states of our views are saved
super.onSaveInstanceState(outState);
// Save our own state now
outState.putSerializable(STATE_ITEMS, mItems);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment