5

I want to swipe between fragments, and I am currently using the viewpager. There is one problem though: When I swipe to the right, entries made in EditTexts of the current fragment need to be validated, and only if the input is ok, it should be swiped to the next page.

I managed to do that by disabling the viewpager when necessary, however then I also cannot swipe to the left (i.e. the previous fragment), since the method to validate the input (onPageScrolled(...)) is not called anymore due to the fact that the viewpager is disabled. It is only enabled again when I type something in the EditText.

I haven't found a way to deal with that problem yet.

So I'd like to know if there is an alternative to using fragments with swipe gestures? Maybe in combination with the viewpager's setCurrentItem() method, but without using the viewpagers scrolling-animation?

deimos1988
  • 5,896
  • 7
  • 41
  • 57
  • Try doing http://stackoverflow.com/questions/13270425/control-which-directions-the-viewpager-can-be-scrolled-dynamically-with-ui-feed The code should be fairly easy to modify to match your needs and you can set your own conditions in your activity that you implement the listener with. – zgc7009 Oct 01 '14 at 20:27
  • 1
    "When I swipe to the right, entries made in EditTexts of the current fragment need to be validated, and only if the input is ok, it should be swiped to the next page" -- IMHO, that is not a valid use of the horizontal swipe gesture. If you want a wizard, build a wizard. – CommonsWare Oct 01 '14 at 21:28
  • @CommonsWare You're right, do you by any chance know either of a tutorial, a library or generally a way to implement a wizard with swipe- capability? – deimos1988 Oct 02 '14 at 11:01
  • 2
    IMHO, a wizard wouldn't have swipe capability. Swiping is for when the *user* has *independent* ability to move between sections of content. A wizard is for when the user does not have independent ability to advance, where you use a disabled "Next" button to prevent advancing until validation requirements on the current wizard page are met. – CommonsWare Oct 02 '14 at 11:16
  • 1
    @CommonsWare What the customer wants the customer gets :) How would you precede given the described requirements? – deimos1988 Oct 02 '14 at 11:24

0 Answers0