Passing A List Through As A Parcelablearraylist
So hey guys, Im having some trouble with some code. Im implementing parcelables. Basically I have an List of items initiated globally as private List mMovieList = new
Solution 1:
Sadly Android doesn't "program to the interface". If the List
is not an ArrayList
then you'll have no choice but to create a new ArrayList
. This isn't a big deal and can be done programmatically.
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
ArrayList<Movie> toSave = mMovieList instanceof ArrayList ?
(ArrayList<Movie>)mMovieList : new ArrayList<Movie>(mMovieList);
outState.putParcelableArrayList(MOVIE_KEY, toSave);
}
Post a Comment for "Passing A List Through As A Parcelablearraylist"