संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Android नेविगेशन में, डायलॉग डेस्टिनेशन शब्द का मतलब डेस्टिनेशन से है
ऐप्लिकेशन के नेविगेशन ग्राफ़ में, जो डायलॉग विंडो का रूप ले लेता है,
ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) एलिमेंट और कॉन्टेंट को ओवरले करना.
क्योंकि डायलॉग डेस्टिनेशन होस्ट किए गए डेस्टिनेशन पर दिखते हैं. इन डेस्टिनेशन पर,
होना चाहिए, तो कुछ ज़रूरी बातों का ध्यान रखना होगा कि डायलॉग कैसे
डेस्टिनेशन आपके NavController के पिछली स्टैक से इंटरैक्ट करते हैं.
@SerializableobjectHome@SerializableobjectSettings@ComposablefunHomeScreen(onNavigateToSettings:()->Unit){Column{Text("Home")Button(onClick=onNavigateToSettings){Text("Open settings")}}}// This screen will be displayed as a dialog@ComposablefunSettingsScreen(){Text("Settings")// ...}@ComposablefunMyApp(){valnavController=rememberNavController()NavHost(navController,startDestination=Home){composable<Home>{HomeScreen(onNavigateToSettings={navController.navigate(route=Settings)})}dialog<Settings>{SettingsScreen()}}}
शुरू होने का डेस्टिनेशन, Home रूट का इस्तेमाल करता है. क्योंकि
composable() इसे ग्राफ़ में जोड़ता है, यह एक होस्ट किया गया गंतव्य है.
दूसरी मंज़िल Settings रूट का इस्तेमाल करती है.
इसी तरह, dialog() इसे ग्राफ़ में जोड़ता है, इसलिए यह एक डायलॉग होता है
गंतव्य.
जब उपयोगकर्ता HomeScreen से SettingsScreen पर जाता है, तो
बाद वाला HomeScreen से ज़्यादा दिखाई देता है.
SettingsScreen में Dialog कंपोज़ेबल शामिल नहीं है, लेकिन
क्योंकि यह एक डायलॉग गंतव्य है, इसलिए NavHost इसे
Dialog.
डायलॉग डेस्टिनेशन, NavHost में पिछले डेस्टिनेशन पर दिखते हैं. इस्तेमाल की जाने वाली चीज़ें
जब डायलॉग आपके ऐप्लिकेशन में कोई ऐसी अलग स्क्रीन दिखाता हो जिसे इसकी अपनी ज़रूरत हो
लाइफ़साइकल और सेव की गई स्थिति, जो आपके
नेविगेशन ग्राफ़. आप AlertDialog या इससे जुड़ी जानकारी का इस्तेमाल कर सकते हैं
यह तब कंपोज़ किया जा सकता है, जब आपको कम मुश्किल प्रॉम्प्ट के लिए डायलॉग चाहिए, जैसे कि
पुष्टि करने के लिए.
Kotlin डीएसएल
अगर फ़्रैगमेंट का इस्तेमाल किया जा रहा है और Kotlin DSL का इस्तेमाल किया जा रहा है, तो
अपना ग्राफ़ बनाना, डायलॉग गंतव्य जोड़ना काफ़ी मिलता-जुलता है
लिखें.
ध्यान दें कि नीचे दिए गए स्निपेट में, कैसे dialog() फ़ंक्शन का इस्तेमाल इन कामों के लिए भी किया जाता है
कोई ऐसा डायलॉग डेस्टिनेशन जोड़ें जो फ़्रैगमेंट का इस्तेमाल करता है:
// Define destinations with serializable classes or objects@SerializableobjectHome@SerializableobjectSettings// Add the graph to the NavController with `createGraph()`.navController.graph=navController.createGraph(startDestination=Home){// Associate the home route with the HomeFragment.fragment<HomeFragment,Home>{label="Home"}// Define the settings destination as a dialog using DialogFragment.dialog<SettingsFragment,Settings>{label="Settings"}}
XML
अगर आपके पास कोई मौजूदा DialogFragment है, तो <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\nIn Android navigation, the term *dialog destination* refers to destinations\nwithin the app's navigation graph which take the form of dialog windows,\noverlaying app UI elements and content.\n\nBecause dialog destinations appear over [hosted destinations](/guide/navigation/design) that fill the\nnavigation host, there are some important considerations regarding how dialog\ndestinations interact with your [`NavController`'s back stack](/guide/navigation/backstack/dialog).\n| **Note:** Dialog destinations implement the [`FloatingWindow`](/reference/androidx/navigation/FloatingWindow) interface. Your app treats any destination that implements this interface as a dialog destination.\n\nDialog composable\n-----------------\n\nTo create a dialog destination in Compose, add a destination to your `NavHost`\nusing the [`dialog()`](/reference/kotlin/androidx/navigation/NavGraphBuilder#(androidx.navigation.NavGraphBuilder).dialog(kotlin.collections.Map,kotlin.Function1)) function. The function behaves essentially the same as\n[`composable`](/reference/kotlin/androidx/navigation/NavGraphBuilder#(androidx.navigation.NavGraphBuilder).composable(kotlin.collections.Map,kotlin.collections.List,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function2))(), only it creates a dialog destination rather than a [hosted\ndestination](/guide/navigation/design).\n\nConsider the following example: \n\n @Serializable\n object Home\n @Serializable\n object Settings\n @Composable\n fun HomeScreen(onNavigateToSettings: () -\u003e Unit){\n Column {\n Text(\"Home\")\n Button(onClick = onNavigateToSettings){\n Text(\"Open settings\")\n }\n }\n }\n\n // This screen will be displayed as a dialog\n @Composable\n fun SettingsScreen(){\n Text(\"Settings\")\n // ...\n }\n\n @Composable\n fun MyApp() {\n val navController = rememberNavController()\n NavHost(navController, startDestination = Home) {\n composable\u003cHome\u003e { HomeScreen(onNavigateToSettings = { navController.navigate(route = Settings) }) }\n dialog\u003cSettings\u003e { SettingsScreen() }\n }\n }\n\n1. The start destination uses the `Home` route. Because `composable()` adds it to the graph, it is a hosted destination.\n2. The other destination uses the `Settings` route.\n - Similarly, because `dialog()` adds it to the graph, it is a dialog destination.\n - When the user navigates from `HomeScreen` to `SettingsScreen` the latter appears over `HomeScreen`.\n3. Although `SettingsScreen` doesn't include a `Dialog` composable itself, because it is a dialog destination, the `NavHost` displays it within a `Dialog`.\n\nDialog destinations appear over the previous destination in the `NavHost`. Use\nthem when the dialog represents a separate screen in your app that needs its own\nlifecycle and saved state, independent of any other destination in your\nnavigation graph. You might prefer to use an [`AlertDialog`](/jetpack/compose/components/dialog) or related\ncomposable if you want a dialog for a less complex prompt, such as a\nconfirmation.\n| **Note:** Because bottom sheets in Compose are not built on `Dialog`, they need their own destination type. See the [Accompanist Navigation Material\n| documentation](https://google.github.io/accompanist/navigation-material/) for an example implementation.\n\nKotlin DSL\n----------\n\nIf you are working with fragments and you are using the [Kotlin DSL](/guide/navigation/design/kotlin-dsl) to\ncreate your graph, adding a dialog destination is very similar to when using\nCompose.\n\nConsider how in the following snippet also uses the [`dialog()`](/reference/kotlin/androidx/navigation/NavGraphBuilder#(androidx.navigation.NavGraphBuilder).dialog(kotlin.Int)) function to\nadd a dialog destination that uses a fragment: \n\n // Define destinations with serializable classes or objects\n @Serializable\n object Home\n @Serializable\n object Settings\n\n // Add the graph to the NavController with `createGraph()`.\n navController.graph = navController.createGraph(\n startDestination = Home\n ) {\n // Associate the home route with the HomeFragment.\n fragment\u003cHomeFragment, Home\u003e {\n label = \"Home\"\n }\n\n // Define the settings destination as a dialog using DialogFragment.\n dialog\u003cSettingsFragment, Settings\u003e {\n label = \"Settings\"\n }\n }\n\nXML\n---\n\nIf you have an existing [`DialogFragment`](/reference/androidx/fragment/app/DialogFragment), use the `\u003cdialog\u003e` element to\nadd the dialog to your navigation graph, as shown in the following example: \n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cnavigation xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n android:id=\"@+id/nav_graph\"\u003e\n\n...\n\n\u003cdialog\n android:id=\"@+id/my_dialog_fragment\"\n android:name=\"androidx.navigation.myapp.MyDialogFragment\"\u003e\n \u003cargument android:name=\"myarg\" android:defaultValue=\"@null\" /\u003e\n \u003caction\n android:id=\"@+id/myaction\"\n app:destination=\"@+id/another_destination\"/\u003e\n\u003c/dialog\u003e\n\n...\n\n\u003c/navigation\u003e\n```"]]