(1)支持手势滑动的ViewFlipper:
重写onTouchEvent方法
private float startX;
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
startX=event.getX();
break;
}
case MotionEvent.ACTION_UP:
{
//向右滑动
if(event.getX()-startX>50)
{
flipper.setInAnimation(this, R.anim.left_in);
flipper.setOutAnimation(this, R.anim.left_out);
flipper.showNext();
}
//向左滑动
if(startX-event.getX()>50)
{
flipper.setInAnimation(this, R.anim.right_in);
flipper.setOutAnimation(this, R.anim.right_out);
flipper.showPrevious();
}
break;
}
}
return super.onTouchEvent(event);
}