admin管理员组文章数量:1344303
I have finished the current (base model) of my ToDoList App, but the app fails to launch after I build & refresh (on Android Studio). I don't know what errors my code currently has, that it fails to launch properly as an app when the build runs. I have added a number of imports, added code fixes, and have tried restarting my Android Studio IDE multiple times.
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activitypose.setContent
import androidx.activity.enableEdgeToEdge
import androidxpose.foundation.layout.Arrangement
import androidxpose.foundation.layout.Column
import androidxpose.foundation.layout.Row
import androidxpose.foundation.layout.fillMaxSize
import androidxpose.foundation.layout.fillMaxWidth
import androidxpose.foundation.layout.padding
import androidxpose.foundation.lazy.LazyColumn
import androidxpose.foundation.lazy.items
import androidxpose.material3.Button
import androidxpose.material3.HorizontalDivider
import androidxpose.material3.MaterialTheme
import androidxpose.material3.OutlinedTextField
import androidxpose.material3.Scaffold
import androidxpose.material3.Surface
import androidxpose.material3.Text
import androidxpose.runtime.Composable
import androidxpose.runtime.getValue
import androidxpose.runtime.mutableStateListOf
import androidxpose.runtime.mutableStateOf
import androidxpose.runtime.remember
import androidxpose.runtime.setValue
import androidxpose.ui.Alignment
import androidxpose.ui.Modifier
import androidxpose.ui.text.font.FontWeight
import androidxpose.ui.tooling.preview.Preview
import androidxpose.ui.unit.dp
import androidxpose.ui.unit.sp
import com.example.firstapriltemplate.ui.theme.FirstAprilTemplateTheme
@Composable
fun App() {
var item by remember { mutableStateOf("") }
val items = remember { mutableStateListOf<String>() }
FirstAprilTemplateTheme {
Column(modifier = Modifier.fillMaxSize()) {
Text(
text = "To Do List!",
fontSize = 32.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(12.dp)
)
Row() {
OutlinedTextField(
value = item,
onValueChange = { item = it },
label = { Text(text = "New Item") }
)
Button(onClick = {
if (item.isNotEmpty()) {
items.add(item) // new item add
item = ""
}
}, modifier = Modifier.padding(14.dp)) {
Text(text = "Save")
}
}
HorizontalDivider()
LazyColumn {
items(items) { task ->
ToDoListItem(name = task)
}
}
}
}
}
@Composable
fun ToDoListItem(name: String) {
Surface(
color = MaterialTheme.colorScheme.background,
) {
Text(text = name, modifier = Modifier.padding(12.dp))
HorizontalDivider()
}
}
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
App()
}
本文标签: kotlinAndroid Build Fails to launch app on current version of Android applicationStack Overflow
版权声明:本文标题:kotlin - Android Build Fails to launch app on current version of Android application - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743741272a2530938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论