T
T
Tsuzukeru2021-08-30 17:50:50
Android
Tsuzukeru, 2021-08-30 17:50:50

How to add back navigation button in navigation component?

Is there a navigation component and an additional back button in the top left corner of the fragment?
How to put a back navigation listener on it?
Need to create an extra action in navigation.xml and use it?
Is there an action in the navcomponent that allows you to return to where you came from?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Siomin, 2021-08-30
@Tsuzukeru

requireActivity().onBackPressed()

G
gazievDima, 2021-08-31
@gazievDima

I worked a little with navigation, but nevertheless I see three options here:
1. Use the onBackPressed method by borrowing it from the activity, but for this the fragment that closes must be called with the addition to the stack.
2. Create an action to switch to the desired window.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question