gpt4 book ai didi

android - 如何在 ListView 中平滑滚动

转载 作者:太空狗 更新时间:2023-10-29 14:20:38 25 4
gpt4 key购买 nike

我正在自动滚动 ListView ,其中有 1000 个项目..通过运行一个运行 smoothscroll 的线程,我让用户通过停止线程直到 ListView 滚动并再次启动线程来滑动 ListView ..每个一切都很好,但问题是滑动后自动滚动与开始之间存在延迟。如何从滑动滚动平滑过渡到自动滚动。

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
--------
--------
ThreadAutoScroll();
}

private void autoScroll() {


if(!touched)
{
listView.smoothScrollBy(1,30);
}

}

public onTouch(Moition event)
{
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
touched = true ;
break;
}
}

public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub

if(touched && scrollState =0)
{
touched = true;
}
}

最佳答案

listview 设置 Smooth Scollbars 如下:

listView.setSmoothScrollbarEnabled(true);

关于android - 如何在 ListView 中平滑滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17296842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com