Thanks for the help, Kostya.
The getScrollY() didn't work, but it got me started to find out a way
that I could save the pixel offset of the top ListView row. And I got
it. It's something like this:
@Override
protected void onPause() {
super.onPause();
this.firstVisiblePosition =
myListView.getFirstVisiblePosition();
this.firstChildTop = myListView.getChildAt(0).getTop();
}
@Override
protected void onResume() {
super.onResume();
this.myListView.setSelectionFromTop(this.firstVisiblePosition,
this.firstChildTop);
}
But I still have the problem that sometimes the ListView is refreshed.
I've noticed that it's sometimes after the onPause(). Very weird. So,
I did my (so far) most ugly hack EVER! I'm sincerely ashamed of this,
and I will deny that this is my code, but... it gets the job done for
now :P
@Override
protected void onResume() {
super.onResume();
this.myListView.setSelectionFromTop(this.firstVisiblePosition,
this.firstChildTop);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
this.myListView.setSelectionFromTop(this.firstVisiblePosition,
this.firstChildTop);
}
}, 200);
}
Cof, cof...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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