a.h*_*ess 8 android kotlin android-studio android-jetpack-compose
我的 MainActivity 看起来是这样的:
class MainActivity : ComponentActivity() {
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BottomNavTheme {
Scaffold(bottomBar = {
BottomNavigation(
backgroundColor = colorResource(id = R.color.teal_200),
contentColor = Color.Black
) {
}
}) {
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
}
我想代码应该没问题。但它会导致“未解析的引用:”错误
我过去已经实现了该功能。这并不难做到。
这里出了什么问题?如何解决这个问题?
有变化吗?我正在使用全新的 Android Studio Flamingo。
确保:
您在应用程序模块的build.gradle文件中添加了此依赖项:
implementation "androidx.compose.material:material:1.4.2"
Run Code Online (Sandbox Code Playgroud)
您导入androidx.compose.material.BottomNavigation到您的MainActivity.kt文件中。
如果您执行了以下所有这些步骤,错误就会消失。如果不是,请尝试使缓存无效并重新启动 Android Studio:
File -> Invalidate caches -> [Mark all options such as clear file system cache etc.] -> Invalidate & Restart
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3354 次 |
| 最近记录: |