সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
অ্যান্ড্রয়েড নেভিগেশনে, ডায়ালগ গন্তব্য শব্দটি অ্যাপের নেভিগেশন গ্রাফের মধ্যে থাকা গন্তব্যগুলিকে বোঝায় যা ডায়ালগ উইন্ডোর রূপ নেয়, অ্যাপের UI উপাদান এবং বিষয়বস্তুকে ওভারলে করে।
যেহেতু ডায়ালগ গন্তব্যগুলি হোস্ট করা গন্তব্যগুলির উপর উপস্থিত হয় যা নেভিগেশন হোস্টকে পূরণ করে, তাই ডায়ালগ গন্তব্যগুলি কীভাবে আপনার NavController এর ব্যাক স্ট্যাকের সাথে ইন্টারঅ্যাক্ট করে সে সম্পর্কে কিছু গুরুত্বপূর্ণ বিবেচনা রয়েছে৷
সংলাপ রচনাযোগ্য
রচনায় একটি ডায়ালগ গন্তব্য তৈরি করতে, dialog() ফাংশন ব্যবহার করে আপনার NavHost এ একটি গন্তব্য যোগ করুন। ফাংশনটি মূলত composable মতোই আচরণ করে, শুধুমাত্র এটি হোস্ট করা গন্তব্যের পরিবর্তে একটি ডায়ালগ গন্তব্য তৈরি করে।
নিম্নলিখিত উদাহরণ বিবেচনা করুন:
@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 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"}}
এক্সএমএল
আপনার যদি একটি বিদ্যমান DialogFragment থাকে, তাহলে আপনার নেভিগেশন গ্রাফে ডায়ালগ যোগ করতে <dialog> উপাদানটি ব্যবহার করুন, যেমনটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে:
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 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-29 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```"]]