קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
במסמך הזה נסביר איך השימוש ביעדים של תיבת דו-שיח יכול להוביל לשיקולים ייחודיים לגבי האופן שבו צריך לנהל את סטאק החזרה.
סקירה כללית
יעד אחד או יותר של תיבת דו-שיח יכולים להתקיים רק בחלק העליון של סטאק החזרה.
הסיבה לכך היא שכאשר המשתמש מנווט ליעד שאינו יעד של תיבת דו-שיח, כל היעדים של תיבות הדו-שיח מוציאים באופן אוטומטי את NavController מהחלק העליון של הסטאק. כך מובטח שהיעד הנוכחי תמיד יהיה גלוי במלואו מעל יעדים אחרים בסטאק העורפי.
אם סטאק החזרה מורכב רק מיעדים מתארחים שממלאים את מארח הניווט, והמשתמש מנווט ליעד של תיבת דו-שיח, סטאק החזרה עשוי להיראות דומה לתרשים 2:
איור 2. סטאק חזרה עם יעד של תיבת דו-שיח בחלק העליון.
אם המשתמש מנווט ליעד אחר של תיבת דו-שיח, הוא מתווסף לחלק העליון של סטאק החזרה, כפי שמוצג באיור 3:
איור 3. סטאק 'הקודם' עם שני Dialog
יעדים בחלק העליון.
אם לאחר מכן המשתמש מנווט ליעד לא צף, כל יעדי התיבת הדו-שיח יוצגו בראש מקבץ הכרטיסיות הקודמות לפני שהמשתמש מנווט ליעד החדש, כפי שמוצג באיור 4:
איור 4. היעדים Dialog נמחקים והיעד החדש מתווסף.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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."]]