[1페이지] [오른쪽으로 플리킹] [2페이지]
위의 그림처럼 1페이지->우 플리킹->2페이지, 2페이지->좌 플리킹->1페이지 이런식으로 보여주고 싶습니다.
이런 기능을 구현하려면 어느 부분을 봐야 하나요?
동작이 홈에서 페이지 이동하는 것과 같습니다. 1페이지에서 터치다운하고 왼쪽으로 drag를 하면 2페이지가 따라 옵니다.
그리고 위의 가운데 이미지에 왔을 때 drag시 멈추면 저렇게 1페이지와 2페이지 사이에서 멈추고 다시 drag하면 2페이지로 이동합니다.
현재 SimpleOnGestureListener에서 onScroll()에서 처리를 해줘야 하는건지요... 아니면 launcher소스를 참고해야 하나요?
경험하신분들의 조언 부탁드립니다. ^^
이런식으로 해보았습니다.
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
//Get the action that was done on this touch event.
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
{
// store the X value when the user's finger was pressed down
downXValue = event.getX();
break;
}
case MotionEvent.ACTION_UP:
{
// Get the X value when the user released his/her finger
float currentX = event.getX();
// going backwards: pushing stuff to the right
if(downXValue < currentX)
{
// Get a reference to the ViewFlipper
ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
// Set the animation
vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out));
// Flip
vf.showPrevious();
}
// going forwards: pushing stuff to the left
if (downXValue > currentX)
{
// Get a reference to the ViewFlipper
ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
// Set the animation
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
// Flip!
vf.showNext();
}
break;
}
}
// if you return false, these actions will not be recorded
return true;
public boolean onTouch(View v, MotionEvent event) {
ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
{
downXValue = event.getX();
break;
}
case MotionEvent.ACTION_UP:
{
float currentX = event.getX();
if(downXValue < currentX) {
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_out));
vf.showPrevious();
}
else if (downXValue > currentX) {
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out));
vf.showNext();
}
break;
}
}
return true;
}수정 해봤습니다.



