如何在ListView适配器中禁用getView()方法?

时间:2013-09-02 09:13:29

标签: java android listview android-listview android-arrayadapter

当我在OnTouchListener中使用MotionEvent.ACTION_MOVE时,有没有办法在ListView适配器中禁用getView()方法?

我需要这样做,因为我尝试用手指移动我的上传者(里面是我的ListView)。我用这个方法setLayoutParams:

    private class MyListener implements View.OnTouchListener{

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        final int Y = (int) event.getRawY();

        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_UP:
                RelativeLayout.LayoutParams paramsUp = (RelativeLayout.LayoutParams) myBar.getLayoutParams();
                paramsUp.topMargin = 0;
                myBar.setLayoutParams(paramsUp);
                break;
            case MotionEvent.ACTION_MOVE:
                RelativeLayout.LayoutParams paramsMove = (RelativeLayout.LayoutParams) myBar.getLayoutParams();
                paramsMove.topMargin = Y - yDelta;

                myBar.setLayoutParams(paramsMove);
                break;
            case MotionEvent.ACTION_DOWN:
                RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) myBar.getLayoutParams();
                yDelta = Y - lParams.leftMargin;
                break;
        }
        //myBar.invalidate();

        return true;
    }

}

当我移动容器时,一切都发生得很慢。这是因为容器更改了其大小,并且所有对象都会再次加载。

我的第二个问题: 当我移动ListView项目时如何取消滚动?例如:向左移动或向右移动。

THX

0 个答案:

没有答案