はそのため、このコード
public class MainActivity extends Activity {
private Integer[] mImageIds = { R.drawable.img1, R.drawable.img2,R.drawable.img3 };
private static final String DEBUG_TAG = "MainActivity ";
ImageView imageView;
float startXValue = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.gallery);
imageView = (ImageView) findViewById(R.id.image_place_holder);
imageView.setImageResource(mImageIds[num]);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float endXValue = 0;
float x1 = event.getAxisValue(MotionEvent.AXIS_X);
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case (MotionEvent.ACTION_DOWN):
startXValue = event.getAxisValue(MotionEvent.AXIS_X);
return true;
case (MotionEvent.ACTION_UP):
endXValue = event.getAxisValue(MotionEvent.AXIS_X);
if (endXValue > startXValue) {
if (endXValue - startXValue > 100) {
System.out.println("Left-Right");
imageView.setImageResource(mImageIds[2]);
}
}else {
if (startXValue -endXValue> 100) {
System.out.println("Right-Left");
imageView.setImageResource(mImageIds[0]);
}
}
return true;
default:
return super.onTouchEvent(event);
}
}
}
使用ビューページャをお試しください – Pavya