3

Hi
I need help in finding a way to store

 ArrayList<HashMap<String,String>> 

in an Bunble object so that i can retrieve them back in onRestoreInstanceState(Bundle state) when an orientation happens .I can find methods to store simple Arrays in an Bunble,but not an ArrayList like this.

1
  • ganesh, is the answer you got satisfying you? I have the same problem here, I can't understand where that weird BitmapDrawable came from. Commented Sep 17, 2012 at 18:45

1 Answer 1

3

first you must have a static holder:

private static class Holder{
        private List<BitmapDrawable>imageList = new ArrayList<BitmapDrawable>();
    }

second, when orientation start, you must return the object you want to retrieve after the orientation:

@Override
    public Object onRetainNonConfigurationInstance() {
        return holder;
    }

at last, when you create the 'new' activity must call getLastNonConfigurationInstance(). ANdroid will return your holder with your List.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                holder = (Holder) getLastNonConfigurationInstance();
}

you can find a more extensive explanation here: Faster Screen Orientation.

cheers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.