Форум для тех, кто программирует под Android
Anonymous
Как исправить «неразрешенные ссылки: композитный» и «Интерфейс -Navhost не имеет конструкторов» в моем композиционном ко
Сообщение
Anonymous » 24 апр 2025, 13:41
Я новичок в Kotlin и Android Studio/Compose, поэтому я не совсем уверен, как это исправить. Я попытался следовать предложениям Android Studio и осмотрел онлайн, но не повезло. Я пытаюсь сделать Navhost для навигации, а Navhost и все композиционные (route =) бросают ошибку. Вот мой код: < /p>
Код: Выделить всё
package com.example.recipesavercompose.navigation
import androidx.compose.runtime.Composable
import androidx.navigation.NavDestination
import androidx.navigation.NavHost
import androidx.navigation.NavHostController
import androidx.navigation.compose.composable
import com.example.recipesavercompose.compose.Culinary_Terms
import com.example.recipesavercompose.compose.Drafts
import com.example.recipesavercompose.compose.Ingredient_Substitutions
import com.example.recipesavercompose.compose.Recipes
import com.example.recipesavercompose.compose.Settings
import com.example.recipesavercompose.compose.View_Recipe
@Composable
fun NavGraph (navController: NavHostController){
val initialDestination = NavDestination.createRoute(Screens.Recipes.route)
NavHost(navController = navController, startDestination = initialDestination)
{
composable(route = Screens.Recipes.route){
Recipes()
}
composable(route = Screens.CulinaryTerms.route){
Culinary_Terms()
}
composable(route = Screens.Drafts.route){
Drafts()
}
composable(route = Screens.IngredientSubstitutions.route){
Ingredient_Substitutions()
}
composable(route = Screens.Settings.route){
Settings()
}
composable(route = Screens.ViewRecipe.route){
View_Recipe()
}
}
}
Я попытался посмотреть на свой импорт, но они казались в порядке.
Подробнее здесь:
https://stackoverflow.com/questions/761 ... t-does-not
1745491299
Anonymous
Я новичок в Kotlin и Android Studio/Compose, поэтому я не совсем уверен, как это исправить. Я попытался следовать предложениям Android Studio и осмотрел онлайн, но не повезло. Я пытаюсь сделать Navhost для навигации, а Navhost и все композиционные (route =) бросают ошибку. Вот мой код: < /p> [code]package com.example.recipesavercompose.navigation import androidx.compose.runtime.Composable import androidx.navigation.NavDestination import androidx.navigation.NavHost import androidx.navigation.NavHostController import androidx.navigation.compose.composable import com.example.recipesavercompose.compose.Culinary_Terms import com.example.recipesavercompose.compose.Drafts import com.example.recipesavercompose.compose.Ingredient_Substitutions import com.example.recipesavercompose.compose.Recipes import com.example.recipesavercompose.compose.Settings import com.example.recipesavercompose.compose.View_Recipe @Composable fun NavGraph (navController: NavHostController){ val initialDestination = NavDestination.createRoute(Screens.Recipes.route) NavHost(navController = navController, startDestination = initialDestination) { composable(route = Screens.Recipes.route){ Recipes() } composable(route = Screens.CulinaryTerms.route){ Culinary_Terms() } composable(route = Screens.Drafts.route){ Drafts() } composable(route = Screens.IngredientSubstitutions.route){ Ingredient_Substitutions() } composable(route = Screens.Settings.route){ Settings() } composable(route = Screens.ViewRecipe.route){ View_Recipe() } } } [/code] Я попытался посмотреть на свой импорт, но они казались в порядке. Подробнее здесь: [url]https://stackoverflow.com/questions/76137730/how-do-i-fix-unresolved-reference-composable-and-interface-navhost-does-not[/url]