TwoWayGridView.scrollTo(x, y) doesn't work
Opened this issue · 3 comments
jfresen commented
I have a TwoWayGridView configured to scroll horizontally that I want to scroll programmatically. I tried to call myGridView.scrollTo(0, 0) to see if it scrolls to the beginning of the list, but it doesn't seem to have any effect.
Probably related is that myGridView.getScrollX() and myGridView.getScrollY() always return 0 in the following code:
final TwoWayGridView myGridView = (TwoWayGridView)view.findViewById(R.id.gridview);
myGridView.setOnScrollListener(new OnScrollListener() {
@Override public void onScrollStateChanged(TwoWayAbsListView view, int scrollState) {}
@Override public void onScroll(TwoWayAbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
myGridView.post(new Runnable() {
@Override public void run() {
Log.i(TAG, "Scrolling to ("+myGridView.getScrollX()+", "+myGridView.getScrollY()+")");
}
});
}
});
tinasolt commented
i have the same problem, could you solve it?
tinasolt commented
i solve it you have to call grid.setStackFromBottom(true); before setting the adapter for the gird, i hope this will help you too.
jfresen commented
Hi,
I solved it by using grid.smoothScrollBy(distance, time) instead, with distance calculated by my logic and time set to 2000. That worked like a charm.
Kind regards,
Jelle