あなたはちょっとしたスワイプをすることができ、配列からの各スワイプ変更アクティビティで、ここに私が考えていることの小さな例があります.
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
int[] values = new int[] {
R.layout.Layout1,
R.layout.Layout2,
R.layout.Layout3 };
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
return false;
}
/**
* left to right swipe
*/
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
//next Layout
setContentView(array[]+1)
/**
* right to left
*/
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
//prev layout
setContentView(array[]-1)
}
}
} catch (Exception e) {
}
return false;
}
これが役に立つことを願っています、乾杯