Однако Android Studio помечает мое текстовое поле этой ошибкой:
Ни один из следующих кандидатов не применим...
Код: Выделить всё
@Composable
fun EditTextONOFF(context: Context, device_number : Int, on_or_off : String, modifier: Modifier) {
val calendar = Calendar.getInstance()
val hourNnw = calendar[Calendar.HOUR_OF_DAY]
val minuteNow = calendar[Calendar.MINUTE]
var hourSet: Int? = 12
var minuteSet: Int? = 0
var timeToShow: String =""
val string_onoff:String = stringResource(R.string.ON)
val device: List = devicesDao?.getItem(device_number) as List
if (on_or_off == string_onoff ) {
hourSet= device.get(0).hour_on
minuteSet = device.get(0).minutes_on
timeToShow= "$hourSet : $minuteSet"
} else {
hourSet = device.get(0).hour_off
minuteSet = device.get(0).minutes_off
timeToShow= "$hourSet : $minuteSet"
}
TextField(
colors= MaterialTheme.colorScheme.onPrimary,
readOnly = false,
enabled = false,
Value= timeToShow,
label = Text(on_or_off) ,
lineLimits = TextFieldLineLimits.SingleLine,
placeholder = Text(stringResource(R.string.click)),
Modifier= Modifier.clickable{
val timePickerDialog = TimePickerDialog(
context,
{ _, selectedHour: Int, selectedMinute: Int ->
hourSet = selectedHour
minuteSet = selectedMinute
},
hourNnw, // Current hour
minuteNow, // Current minute
false // false = 12-hour format
)
if (on_or_off == string_onoff ) {
device.get(0).hour_on = hourSet
device.get(0).minutes_on = minuteSet
} else {
device.get(0).hour_off = hourSet
device.get(0).minutes_off = minuteSet
}
timeToShow= "$hourSet : $minuteSet"
}
)
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -applicabl