Android中Activity中左右滑动手势的监听

/*
	 * 完成对左右划屏
	 */
	@Override
	public boolean onTouchEvent(MotionEvent event) {

		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			prev.set(event.getX(), event.getY());

			break;
		case MotionEvent.ACTION_UP:
			break;

		case MotionEvent.ACTION_MOVE:

			float moveX = prev.x - event.getX();

			// 左滑
			if (moveX > 150 && moveX < 5000) {
				// mDesignClothesBackground
				// .setBackgroundResource(idClothesBackground[0]);
			}
			// 右滑
			else if (moveX < -150 && moveX > -5000) {
				// mDesignClothesBackground
				// .setBackgroundResource(idClothesBackground[1]);
			}

		}

		return false;
	}


 
 

你可能感兴趣的:(Android参考)