NavController ve NavHost
Uygulamanızın gezinme grafiğini tanımlayın.
NavController ve NavHost, CoddyKit'te ücretsiz bir Jetpack Compose Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Jetpack Compose Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Moving Between Screens
Real apps have many screens. Navigation Compose is the official library that lets you move between them without juggling fragments or activities. 🧭
Add the Dependency
Navigation lives in its own artifact. Add androidx.navigation:navigation-compose to your module's build file before you can use any of it.
dependencies {
implementation("androidx.navigation:navigation-compose:2.7.7")
}Meet the NavController
The NavController is the brain of navigation. It tracks where you are, remembers history, and carries out every move you ask for.
Remember the Controller
You create one with rememberNavController() so it survives recomposition. Make it once near the top of your app and pass it down.
val navController = rememberNavController()Meet the NavHost
The NavHost is the container that swaps screens in and out. It shows exactly one destination at a time, based on the controller.
Wire Host to Controller
A NavHost needs two things: the navController that drives it and a startDestination that says which screen to show first.
NavHost(
navController = navController,
startDestination = "home"
) { }The startDestination
The startDestination is the route shown when the app opens. It is also the screen users land on after the back stack empties.
Declaring Destinations
Inside the NavHost lambda you list your screens with composable("route"). Each one ties a route name to the UI it should show.
NavHost(navController, startDestination = "home") {
composable("home") { HomeScreen() }
composable("profile") { ProfileScreen() }
}Navigate by Route
To change screens, call navController.navigate("route"). The host sees the request and swaps in the matching destination instantly.
Button(onClick = { navController.navigate("profile") }) {
Text("Open profile")
}One Controller, One Host
Keep a single NavController paired with a single NavHost for an app's main flow. Sharing one source of truth avoids confusing, out-of-sync history.
Why Routes Are Strings
Routes are just String identifiers, like tiny URLs inside your app. This keeps destinations decoupled and easy to link later.
Quick Check
Which piece actually performs the screen change?
Recap
You met the duo behind navigation: the NavController drives moves and history, while the NavHost shows one destination at a time from your route list. 🎉
Sıkça Sorulan Sorular
“NavController ve NavHost” dersi ücretsiz mi?
Evet — “NavController ve NavHost” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Jetpack Compose Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.
“NavController ve NavHost” dersinde ne öğreneceğim?
Uygulamanızın gezinme grafiğini tanımlayın. Jetpack Compose Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Jetpack Compose Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Jetpack Compose Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.
“NavController ve NavHost” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Jetpack Compose Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Jetpack Compose Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- NavController ve NavHost
- Composable Hedefleri ve Rotalar
- Ekranlar Arasında Bağımsız Değişken Aktarma
- Geri Yığını ve Derin Bağlantılar