无法检测到动作

时间:2014-05-29 19:52:49

标签: android events action

当我无法检测到操作停止事件时,我遇到了问题。我希望按照链接:http://www.javacodegeeks.com/2013/06/android-listview-pull-to-refresh.html对列表视图执行pull-to-refresh。

@Override
public boolean onTouchEvent(MotionEvent event) {
    //System.out.println("First ["+this.getFirstVisiblePosition()+"]");

    float y = event.getY();

    switch (event.getAction()) {
        case MotionEvent.ACTION_MOVE: {
            Log.d(LOG_TAG, "MOVE");
            if ( ( y - startY) > THRESHOLD && STATE_REFRESH_ENABLED && !STATE_REFRESHING ) {

            }
        }
        break;
        case MotionEvent.ACTION_DOWN: {
            Log.d(LOG_TAG, "DOWN");
            startY = y;
            STATE_REFRESH_ENABLED = getFirstVisiblePosition() == 0; // We are on the first element so we can enable refresh
        }
        case MotionEvent.ACTION_UP: {
            Log.d(LOG_TAG, "UP");
            STATE_REFRESHING = false;
        }

    }
    return super.onTouchEvent(event);
}

根据记录,未检测到acion。提前谢谢。

0 个答案:

没有答案