How to Put a custom ArrayAdapter in savedInstanceState?

Put your problem here if it does not fit any of the other categories.

How to Put a custom ArrayAdapter in savedInstanceState?

Postby Sigma » Fri Jan 07, 2011 9:54 am

I've created my own class of ArrayAdapter, ArrayAdapter<WebObject>, where WebObject is a simple class I've created.

Now I wish to send this arrayadapter into savedInstanceState for safekeeping when the user rotates the device to quicker restore the application state. How can I achieve this?
I can't find any general method to store general objects in the bundle.
Sigma
Developer
Developer
 
Posts: 33
Joined: Thu Dec 16, 2010 12:34 pm

Top

Re: How to Put a custom ArrayAdapter in savedInstanceState?

Postby Skiller » Sat Jan 08, 2011 11:25 am

Look into onRetainNonConfigurationInstance and getLastNonConfigurationInstance as they are what you are supposed to be using to deal with orientation changes. I believe it is also strongly advised that you don't store any UI related classes during an orientation change as they can contain references to the application and cause the whole application to be leaked, so be careful with exactly what you hold onto.
Skiller
Developer
Developer
 
Posts: 33
Joined: Sun Nov 28, 2010 8:35 pm
Location: Australia

Re: How to Put a custom ArrayAdapter in savedInstanceState?

Postby Sigma » Sat Jan 08, 2011 1:26 pm

Ah, nice! Thank you! :-)

That does exactly what I'm after.
Sigma
Developer
Developer
 
Posts: 33
Joined: Thu Dec 16, 2010 12:34 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests