There is a main fragment that is attached to a menu item in the navigation bar.
There is a button in the fragment, when clicked, the next fragment opens via findNavController().navigate(R.id.action)
How can I make it so that when I click on the button on the navigation bar, I reopen the main fragment?
At the moment, nothing happens and I just stay in the opened child fragment.
An example of such an implementation is in the YouTube application. There is a "Subscriptions" button on the navigation bar, which leads to a fragment with channels that I subscribe to. Next, you can select a channel and a fragment of the channel view will open. And if you then click on the "Subscriptions" button again, the main fragment will open again.
from Android Navigation Bar: How to always navigate to the main fragment when selecting an item in the navigation bar?
No comments:
Post a Comment