kotlin - Android Build Fails to launch app on current version of Android application - Stack Overflow

I have finished the current (base model) of my ToDoList App, but the app fails to launch after I build

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()
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743741273a4499189.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信