1

I'm trying the CommonsWare's android endlist adapter.

https://github.com/commonsguy/cwac-endless

After loading a couple of pages, i rotated the screen, and the listview loses all the pages except the first one. Doesn't it supposed to retain the loaded items?

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
syloc
  • 4,569
  • 5
  • 34
  • 49

1 Answers1

1

Doesn't it supposed to retain the loaded items?

That is your job, not the adapter's. Adapters do not "retain" "items", regardless of whether EndlessAdapter is involved or not.

By default, activities are destroyed and recreated when the device undergoes a configuration change, such as a screen rotation. You need to arrange to hang onto your model data when this occurs, by:

  • using setRetainInstance() on a dynamic fragment, or
  • using onSaveInstanceState(), or
  • using onRetainNonConfigurationInstance(), or
  • in the worst case, using android:configChanges, as suggested in another answer
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • OK @CommonsWare. Will it be different if i use a loader with the adapter? – syloc Feb 28 '13 at 21:43
  • @syloc: Well, `EndlessAdapter` does not work with a `CursorAdapter` AFAIK. That being said, a properly-implement `Loader` would help you retain your data across configuration changes. – CommonsWare Mar 01 '13 at 02:06