[android-developers] Re: Saved Instance State and ListViews

2008-10-10 Thread Stoyan Damov

I don't think that would work. You'll need to manually serialize the items.

On Fri, Oct 10, 2008 at 4:49 PM, Mark Hansen [EMAIL PROTECTED] wrote:

 I think I'm missing something... I want to do something like.  I have
 the list Adapater being set to a custom adapter... so I was trying to
 do it this way..

@Override
public void onSaveInstanceState(Bundle savedInstanceState)
{
savedInstanceState.putSerializable(listview, (Serializable)
 getListAdapter());

}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState)
{

setListAdapter((MyCustomListAdapter)
 savedInstanceState.getSerializable(listview));

}

 On Oct 10, 9:40 am, Stoyan Damov [EMAIL PROTECTED] wrote:
 I don't get the question - just serialize the items into the bundle?
 Am I missing something here?

 On Fri, Oct 10, 2008 at 4:31 PM, Mark Hansen [EMAIL PROTECTED] wrote:

  I have a ListView I'm populating with a call to an XML feed, and I'd
  like to save it when the orientation flips to save a reload.

  I've read that you can Override the onSaveInstanceState and store your
  information there, but I can't figure out how to save the values of a
  ListView?

  Am I on the right path or am I doing something wrong?


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Saved Instance State and ListViews

2008-10-10 Thread Mark Hansen

The list is pulled from a remote feed over the web, so I was trying to
prevent having to reload the listview via another web pull.

Basically I just want the application to save everything and then
restore itself when the user changes orientation, instead of having to
make another full call back data source.



On Oct 10, 10:09 am, Mark Murphy [EMAIL PROTECTED] wrote:
 Stoyan Damov wrote:
  I don't think that would work. You'll need to manually serialize the items.

 Or, if the actual ListAdapter contents are already stored somewhere
 (e.g., database), just store transient state, like the selected position
 and visible items.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 1.3 Published!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Saved Instance State and ListViews

2008-10-10 Thread Mark Hansen

Thanks for the input.. I ended up just saving out my data from the
pull as suggested, it was already an ArrayList and I just jammed it in
with the putSerializable and it works fine.

Thanks for the help guys.

On Oct 10, 10:26 am, Mark Murphy [EMAIL PROTECTED] wrote:
 Mark Hansen wrote:
  The list is pulled from a remote feed over the web, so I was trying to
  prevent having to reload the listview via another web pull.

 I would recommend storing the data from the feed somewhere other than
 just in the ListView itself. Database, XML file, JSON file, whatever. If
 you go with the database option, you can use a CursorAdapter and still
 only have one copy of the data -- just in a spot that is designed to
 live longer.

  Basically I just want the application to save everything and then
  restore itself when the user changes orientation, instead of having to
  make another full call back data source.

 Understood, but I suspect the instance-state mechanism isn't designed
 for large data sets.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 1.3 Published!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Saved Instance State and ListViews

2008-10-10 Thread Mark Murphy

Mark Hansen wrote:
 The list is pulled from a remote feed over the web, so I was trying to
 prevent having to reload the listview via another web pull.

I would recommend storing the data from the feed somewhere other than 
just in the ListView itself. Database, XML file, JSON file, whatever. If 
you go with the database option, you can use a CursorAdapter and still 
only have one copy of the data -- just in a spot that is designed to 
live longer.

 Basically I just want the application to save everything and then
 restore itself when the user changes orientation, instead of having to
 make another full call back data source.

Understood, but I suspect the instance-state mechanism isn't designed 
for large data sets.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.3 Published!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---