RadioButton
@Composable
fun RadioButton(
selected: Boolean,
onClick: (() -> Unit)?,
modifier: Modifier = Modifier,
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: RadioButtonColors = RadioButtonDefaults.colors()
):Unit
- checked 是否选中
- onCheckedChange 选择回调
- enabled 是否启用
@Composable
fun RadioButtonSample1() {
var checkedList by remember { mutableStateOf(listOf(false, false)) }
LazyColumn() {
items(checkedList.size) { i ->
RadioButton(selected = checkedList[i], onClick = {
checkedList = checkedList.mapIndexed { j, _ ->
i == j
}
})
}
}
}
视频教程
https://www.bilibili.com/video/BV1xq4y1475H
实战视频