0

Possible Duplicate:
Maintain/Save/Restore scroll position when returning to a ListView

how to save scroll position in the ListView? I should to add elements into the head of the ListView and into an arbitrary position, but visual part should NOT be scrolled.

for example I have 123 elements, I see 1/2 part of the element with index 66 (elements have a different height). I added an element into the list, and I should to see 1/2 part of the element with index 67 (previously index 66).

you can see as example - default "SMS" application for windows phone 7.5. This application uses the lazy-loading

Community
  • 1
  • 1
monyag
  • 690
  • 2
  • 8
  • 27

1 Answers1

0

you can use getSelection() and setSelection() method

Get the current selection using getSelection() and when you comes back to that ListView again the call setSelection()

MAC
  • 15,363
  • 8
  • 51
  • 92
  • it's not worked for me... android 2.3.3 – monyag Jun 27 '12 at 04:45
  • Sorry, it's worked, if I use this setter as myListView.post(new Runnable ...setSelection()...);. but after the notifyDataChanged scroll setted into the 0 position (visually), and setted to my position later. scroll position will not be stored :( – monyag Jun 28 '12 at 03:25