0

Hello fellow Stackoverflowers,

In my application there are three top destination fragments all switchable through a navigation drawer, just like in the navigation drawer template. Now there is an additional button at the home fragment with the purpose of changing to another fragment by clicking it.

I tried doing it like this:

    startButton.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            NavHostFragment.findNavController(HomeFragment.this).navigate(R.id.nav_slideshow);
        }
    });

This works as long if you hit the on screen back button to navigate back to the home screen. but if not it breaks the navigation drawer. You will no longer be able to navigate home after clicking the button by using the navigation drawer. You will always land to the fragment you landed after clicking the fragment switch button

I have tried adding actions in the navigation.xml but it didnt work.

Does anyone have a solution for this?

Thank you in advance!

ILurch
  • 23
  • 6
  • I don't understand your question. You say that, if you press on `startButton` it will go from A to B, now you click on back arrow it come back to A. Now what is the problem? – C.F.G Jun 30 '23 at 18:39
  • After pressing the startButton to get from A to B the Navigation Drawer wont let me go back to A i have to press the back button at the bottom of the phone. (the triangle one) – ILurch Jun 30 '23 at 18:59
  • 1
    https://stackoverflow.com/q/51043428/6576302 – C.F.G Jun 30 '23 at 19:54

0 Answers0