0

I don't have any specific code for this, since I'm not sure how to approach it. Basically I want to be able to slide the screen when swiped, but I want to stop the screen from sliding when I press a specific button. I'm trying to make a game and the tutorial would involve slides to explain it, but I want a button at the last slide to start the game and the end the tutorial. If I leave it as is, the player could swipe left and go back to the tutorial, which would be weird. How should I do this? Thank you in advance!

1 Answers1

0

What if you changed the viewpager's visibility to "gone" after the end tutorial button click?

Alternatively, you could look at this answer to see how to disable viewpager's swipe functionality.

A whole another approach would be to take the tutorial to another level - you could use DialogFragment with a custom view to do that.

DanDayne
  • 154
  • 6
  • Oh, thank you so much! I didn't know that was an option! – Beep Boop Nov 21 '20 at 16:47
  • Just make sure to make changes to view only on UI thread, otherwise the app will crash. Just use Activity.runOnUiThread method when you change the visibility of a View. I still believe that a DialogFragment would be a better option for what you are trying to do, though. – DanDayne Nov 21 '20 at 16:56