I have a scenario where i have to enable swiping from fragment of viewpager and when all swiping being done from fragment then i have to allow viewpager swiping to move to next fragment. I am not able to figure this out.
For eg i have 4 text view in a fragment then first textview should come on first swipe right and if user swipe again to the right then next textview should appear and so on untill all 4 textview should loaded in fragment then viewpager swiping should be enable.
I have used setOnTouchListener on layout of my fragment inside viewpager but its now working.
setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN: {
oldTouchValue = event.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = event.getX();
if (oldTouchValue < currentX) {
// swiped left
}
if (oldTouchValue > currentX) {
// swiped right
}
break;
}
}
System.out.println("TOuch ");
return false;
}
});
Please help me to resolve this issue.