Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
W tym dokumencie opisujemy, jak korzystanie z miejsc docelowych okien może wprowadzić wyjątkowe uwagi w zakresie zarządzania stosem wstecznym.
Przegląd
Co najmniej 1 miejsce docelowe okien może znajdować się tylko na górze stosu wstecznego.
Dzieje się tak, ponieważ gdy użytkownik przechodzi do miejsca docelowego, które nie jest miejscem docelowym okna, NavController automatycznie wysuwa wszystkie miejsca docelowe okien poza stos. Dzięki temu bieżące miejsce docelowe będzie zawsze w pełni widoczne nad innymi miejscami docelowymi w stosie wstecznym.
Jeśli stos wsteczny składa się wyłącznie z hostowanych miejsc docelowych, które wypełniają hosta nawigacji, a użytkownik przechodzi do miejsca docelowego okna, stos wsteczny może wyglądać podobnie do tego na rysunku 2:
Rysunek 2. Stos wsteczny z miejscem docelowym okna u góry.
Jeśli użytkownik przejdzie następnie do innego miejsca docelowego okna, zostanie ono dodane na początek stosu wstecznego, jak widać na ilustracji 3:
Rysunek 3. Stos wsteczny z 2 miejscami docelowymi na górze Dialog.
Jeśli użytkownik następnie przejdzie do miejsca docelowego niepływającego, wszystkie miejsca docelowe w oknach zostaną najpierw pobrane z góry stosu wstecznego, zanim przejdą do nowego miejsca docelowego, jak widać na ilustracji 4:
Rysunek 4. Miejsca docelowe Dialog zostaną wyświetlone i dodane zostanie nowe miejsce docelowe.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],null,["# Dialog destinations\n\nThis document outlines how the use of [dialog destinations](/guide/navigation/design) can introduce\nunique considerations for how you need to manage your back stack.\n\nOverview\n--------\n\nOne or more dialog destinations can only exist on the top of the back stack.\nThis is because when the user navigates to a destination that is not a dialog\ndestination, the `NavController` automatically pops all dialog destinations off\nthe top of the stack. This ensures that the current destination is always fully\nvisible over other destinations on the back stack.\n\nDestinations can be either [hosted destinations](/guide/navigation/design), [activity\ndestinations](/guide/navigation/design/activity-destinations), or [dialog destination](/guide/navigation/design/dialog-destinations).\n| **Note:** Dialog destinations implement the [`FloatingWindow`](/reference/androidx/navigation/FloatingWindow) interface. As such, they overlay other destinations on the back stack.\n\nExample\n-------\n\nIf the back stack consists solely of [hosted destinations](/guide/navigation/design)\nthat fill the navigation host, and the user navigates to a dialog destination,\nthen the back stack might look similar to figure 2:\n**Figure 2.** A back stack with a dialog destination on top.\n\nIf the user then navigates to another dialog destination, it is then added to\nthe top of the back stack, as shown in figure 3:\n**Figure 3.** A back stack with two `Dialog` destinations on top.\n\nIf the user then navigates to a non-floating destination, any dialog\ndestinations are first popped from the top of the back stack before navigating\nto the new destination, as shown in figure 4:\n**Figure 4.** The `Dialog` destinations are popped, and the new destination is added."]]