Я получаю сообщение об ошибке неоднозначности в моем Text Composable, и, похоже, этой проблемы нет никакого решения. Я получаю сообщение об ошибке только при использовании Text Composables.
Код: Выделить всё
@Composable
fun Add(navController: NavController) {
val regularity = listOf(
Regularity.None,
Regularity.Daily,
Regularity.Weekly,
Regularity.Monthly,
Regularity.Yearly
)
var selectedRegularity by remember {
mutableStateOf(regularity[0])
}
val categories = listOf("Education", "Home", "Personal", "Hygiene")
var selectedCategory by remember {
mutableStateOf(categories[0])
}
//Adding Context
val mContext = LocalContext.current
//Defining Calender Parameter
val calenderYear: Int
val calenderMonth: Int
val calenderDay: Int
val mCalendar = Calendar.getInstance()
calenderYear = mCalendar.get(Calendar.YEAR)
calenderMonth = mCalendar.get(Calendar.MONTH) + 1
calenderDay = mCalendar.get(Calendar.DAY_OF_MONTH)
val mDate by Remember {
mutableStateOf(
"${mCalendar.get(Calendar.DAY_OF_MONTH)} -${mCalendar.get(Calendar.MONTH) + 1}-${
mCalendar.get(
Calendar.YEAR
)
}"
)
Scaffold(
topBar = {
MediumTopAppBar(
title = { Text(text = "Add") },
colors = TopAppBarDefaults .mediumTopAppBarColors(
ContainerColor = TopAppBarBackground
)
)
},
content = {innerPadding ->
Column(
modifier = Modifier. padding(innerPadding),
HorizontalAlignment = Alignment.CenterHorizontally
)
{
Column(
модификатор = Modifier
.padding(16.dp)
.clip(Shapes.large)
.background(BackgroundElevated)
.fillMaxWidth()
) {
//Строка суммы
TableRow(label = "Сумма ") {
TextFieldUnstyled(
value = "Waa",
onValueChange = {},
modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(textAlign = TextAlign.Right),
KeyboardOptions = KeyboardOptions(
KeyboardType = KeyboardType.Number
)
)
Divider(
модификатор = Модификатор .padding(start = 16.dp),
Thickness = 1.dp,
color = DividerColor
)
//Row Regularity
TableRow(label = "Regularity Row
TableRow(label = "Regularity Row ") {
var RegularityMenuOpened с помощью Remember {
mutableStateOf(false)
TextButton(
onClick = { RegularityMenuOpened = true },
shape = Shapes .large
) {
Text(selectedRegularity.name)
DropdownMenu(expanded = RegularityMenuOpened, onDismissRequest = {
RegularityMenuOpened =
false
}) {
Regularity.forEach { регулярность ->
DropdownMenuItem(text = { Text(text = Regularity.name) } ,
onClick = {
selectedRegularity = регулярность
RegularityMenuOpened = false
})
Разделитель (
модификатор = Modifier.padding(start = 16.dp),
толщина = 1.dp,
цвет = DividerColor
)
//Строка даты
TableRow(label = "Date") {
Divider(
modifier = Modifier.padding(start = 16 .dp),
Thickness = 1.dp,
color = DividerColor
)
//Строка примечаний
TableRow(label = "Note") {
TextFieldUnstyled(
value = "",
Placeholder = { Text("Оставьте здесь несколько примечаний") },
Arrangement.End,
onValueChange = {},< br /> модификатор = Modifier.fillMaxWidth(),
textStyle = TextStyle(textAlign = TextAlign.Right),
)
Divider(
модификатор = Modifier. padding(start = 16.dp),
толщина = 1.dp,
цвет = DividerColor
)
//Строка категорий
TableRow(label = "Категория") {
var CategoryMenuOpened by Remember {
mutableStateOf(false)
TextButton(onClick = {categoryMenuOpened = true }, shape = Shapes.large) {
Text(selectedCategory)
DropdownMenu(
расширенное = CategoryMenuOpened,
onDismissRequest = {categoryMenuOpened = false }) {
категории.forEach { категория ->
DropdownMenuItem(text =
{
Row(verticalAlignment = Alignment.CenterVertically) {
Surface(
модификатор = Modifier.size(10) .dp),
shape = CircleShape,
color = Primary
) {
Text(
text = Category,
модификатор = Modifier.padding(start = 8.dp)
)
},
onClick = {
selectedCategory = Category
Button(
onClick = { /*TODO*/ },
модификатор = Modifier.padding(16.dp),
shape = Shapes.large
) {
Text(text = "Отправить расход")
)
Код: Выделить всё
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.chirayu.financeapp.components.TableRow
import com.chirayu.financeapp.components.TextFieldUnstyled
import com.chirayu.financeapp.models.Regularity
import com.chirayu.financeapp.ui.theme.BackgroundElevated
import com.chirayu.financeapp.ui.theme.DividerColor
import com.chirayu.financeapp.ui.theme.FinanceAppTheme
import com.chirayu.financeapp.ui.theme.Primary
import com.chirayu.financeapp.ui.theme.Shapes
import com.chirayu.financeapp.ui.theme.TopAppBarBackground
import java.util.Calendar
Источник: https://stackoverflow.com/questions/781 ... oid-studio