viewFli = (ViewFlipper) this.findViewById(R.id.ViewFlipper1); viewFli.setOnTouchListener(this); detector = new GestureDetector(this);@Override public boolean onDown(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (e1.getX() - e2.getX() > 0) { this.viewFli.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in)); this.viewFli.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out)); this.viewFli.showPrevious(); } else { this.viewFli.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_in)); this.viewFli.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_out)); this.viewFli.showNext(); } return true; } @Override public void onLongPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // TODO Auto-generated method stub return false; } @Override public void onShowPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub this.detector.onTouchEvent(arg1); return true; }
in_left.xml
in_right.xml