Created
September 15, 2020 14:28
-
-
Save baggednismo/0e6823caf6026d9ecf99f3b8fceb3b9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
btnContinue.setOnClickListener { | |
if (pager.currentItem < pager.adapter?.itemCount!! - 1) { | |
handler.removeMessages(0) | |
pager.currentItem = ++pager.currentItem | |
} | |
} | |
// I expect the back button to be hidden when ViewPager2 is at position 0 | |
btnBack.setOnClickListener { onBackPressed() } | |
... | |
} | |
override fun onBackPressed() { | |
if (pager.currentItem == 0) super.onBackPressed() | |
else { | |
handler.removeMessages(0) | |
pager.currentItem = --pager.currentItem | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment