我在Jetpack Compose中有一个列表项,我想在我的项目中按onLongClick
项目添加上下文菜单,但我在互联网上没有找到任何资源。有什么想法吗?
@Composable
fun MyScreen() {
val textState = remember { mutableStateOf(TextFieldValue("")) }
val listOfData = listOf(
MyUser(“Davidson” :),
MyUser(“Angel” :),
MyUser(“Marry” :),
)
Column(
modifier = Modifier
.fillMaxSize()
) {
LazyColumn(
modifier = Modifier
) {
items(listOfData.size) { index ->
DataListItem(listOfData[index]) {
}}}}}
fun DataListItem(
data: MyUser,
onLongClick: () -> Unit
) {
val context = LocalContext.current
val interactionSource = remember { MutableInteractionSource() }
Column(
) {
val expanded = remember { mutableStateOf(false)}
Row(
modifier = Modifier
.fillMaxWidth()
.combinedClickable(
onLongClick = { expanded.value = true
onLongClick()
},
) ) {
Column(
horizontalAlignment = Alignment.Start,
) {
Text(
text = data.user,
) } }