Use backstack with ViewPager

后端 未结 5 1399
栀梦
栀梦 2021-01-02 09:44

I am using a ViewPager to implement swiping in my android app. However, I would like the previous fragment to be shown when the user uses the back button instead of ending t

5条回答
  •  走了就别回头了
    2021-01-02 10:07

    If you are using the Jetpack Navigation component, chances are you have a single activity and are trying to manage the backstack inside a fragments. In which case the OnBackPressedDispatcher comes handy.

提交回复
热议问题