Monday, 9 September 2013

auto-scrolling of adapterView

auto-scrolling of adapterView

Background
I'm trying to make an adapterView (listview, gridview,...) to slowly auto
scroll .
the user can toggle it whenever he wishes, and it doesn't necessary move
all the way to the bottom.
What I've tried
for this, i'm using the next code:
private static final SCROLLING_RUNNABLE = new Runnable() {
@Override
public void run() {
final int duration = 10;
final int pixelsToMove = 1;
mAdapterView.smoothScrollBy(pixelsToMove, duration);
mHandler.postDelayed(this, duration);
}
};
...
mHandler.post(SCROLLING_RUNNABLE);
The problem
the code usually works, but on some cases, it takes a long time till the
scrolling starts.
in fact, it seems that the more i turn it on and off, the more i will have
to wait for it to start auto-scrolling.
since i can't find out how to get the current scrolling value of the
adapterView, i can't find out how to fix this issue.
The question
What can I do in order to fix this issue ?

No comments:

Post a Comment