0

I have an issue with my Android app that uses Navigation and ViewPager2.

I've the main Activity which implements a Navigation Drawer and has its own Navigation Graph and it works fine with the rest of the application.

Then I have a second Activity that has a ViewPager2 which displays 3 different Fragments. Now the problem is that I need to navigate from the Main Activity to the Pager activity keeping the original Navigation infrastructure. I know that each activity has it's own Navigation Graph, but the second activity has a ViewPager2 control so that means it has 3 Fragments and I cannot specify a startDestination in the new Navigation Graph .... because there are 3 and here is the problem. I can display the new activity but the Application Bar with the Back button which would navigate to the original activity is not displayed. Any solution ?

Sergiob
  • 838
  • 1
  • 13
  • 28

1 Answers1

0

You can not handle fragment of viewpager through nav graph, but you can create parent fragment called ViewPagerTabsHolderFragment and inside it, you will set up the view pager adapter fragments then you can set the nav graph start destination to this ViewPagerTabsHolderFragment

Biro Nader
  • 119
  • 5