2

I'm trying to get data stored in parts of a ListView. However, when a View scrolls off the page, the View is destroyed.

How do I tell the ListView not to destroy content that goes off screen?

Community
  • 1
  • 1
Muz
  • 5,866
  • 3
  • 47
  • 65
  • That's how it works and for memory management. If u dont want that then you might have to go for ScrollView which will lead you to memory issues soon – Andro Selva Sep 06 '12 at 08:01
  • Sometimes you want the efficient method. Sometimes you want to keep all of it. It would be nice to quickly toggle. – Muz Sep 06 '12 at 08:06
  • You can always access the data from a listview from his adapter. The objects from adapter are not destroyed when the view is recycled. – Ungureanu Liviu Sep 06 '12 at 08:18
  • @UngureanuLiviu If you know a way to access the data from the adapter without taking it from ListView, I would be grateful if you could answer the linked question :) – Muz Sep 06 '12 at 08:27
  • :) No, I don't know such a I way but I was thinking about (MyObjectFromAdapter)mylistview.getAdapter().getItem(position) – Ungureanu Liviu Sep 06 '12 at 08:34

1 Answers1

2

If you don't want a view to be destroyed in your Listview you need to change to a Scrollview instead of a Listview. The whole point of a Listview is to display a lot of data efficiently.

Ceetn
  • 2,728
  • 2
  • 25
  • 28