Last active
August 29, 2015 14:27
-
-
Save noaht11/abdabc2f7f276bcaffcb to your computer and use it in GitHub Desktop.
Saving state for a ListView
This file contains 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
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