我正在尝试自动滚动listview直到达到最低点。 Listview应该像动画一样慢慢滚动。 我使用下面的代码滚动listview和listview自动滚动工作,但问题是listview不滚动直到到达底部中途listview停止滚动
orderlistview.smoothScrollToPositionFromTop(orderlist.size(), 0, 2000);
答案 0 :(得分:-1)
试试这个
int index = 1;
int listviewCount = mAdapter.getCount();
Runnable runnable;
int ANIMATION_TIME = 1000;
Handler handler = new Handler();
handler.postDelayed(runnable = new Runnable() {
@Override
public void run() {
if(listviewCount >= index){
handler.removeCallbacks(runnable);
} else {
orderlistview.smoothScrollToPosition(index);
index = index + 1;
handler.postDelayed(runnable , ANIMATION_TIME);
}
}
}, 0);
删除onPause()
中的回调 handler.removeCallbacks(runnable);