Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在listview中获得平滑滚动_Android_Listview - Fatal编程技术网

Android 如何在listview中获得平滑滚动

Android 如何在listview中获得平滑滚动,android,listview,Android,Listview,我正在自动滚动列表视图,其中有1000个项目。通过运行运行smoothscroll的线程,我让用户通过停止线程直到列表视图滚动并再次启动线程来滑动列表视图。。一切都很好,但问题是刷卡后自动滚动与启动之间存在延迟。。如何从滑动滚动平滑过渡到自动滚动 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); --------

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

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.setSmoothScrollbarEnabled(true);

请在您的代码中简单地尝试此代码。我希望这会有帮助

 GestureDetector mGD = new GestureDetector(getBaseContext(),
        new SimpleOnGestureListener() {

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
// beware, it can scroll to infinity
scrollBy((int)distanceX, (int)distanceY);
return true;
}

private void scrollBy(int distanceX, int distanceY) {
distanceX =10;
distanceY =10;
}

@Override
public boolean onDown(MotionEvent e) {
if(!mScroller.isFinished() ) { // is flinging
mScroller.forceFinished(true); // to stop flinging on touch
}
return true; // else won't work
}
});

@Override
public boolean onTouchEvent(MotionEvent event) {
return mGD.onTouchEvent(event);
}

我问的。。你回答了什么。。?