简体   繁体   English

将 onClickLabel 添加到撰写框

[英]Adding onClickLabel to compose box

I'm starting out on compose and I've created a clickable box.我开始编写并创建了一个可点击的框。 For accessibility purposes I'm trying to add the onClickLabel, but I'm having no joy.出于可访问性的目的,我正在尝试添加 onClickLabel,但我没有任何乐趣。 Does anyone know how to do this?有谁知道如何做到这一点?

Look so simple.看起来很简单。

Box(Modifier.fillMaxWidth().clickable { /*Call your function here*/ }) {
                Text(
                    "Simple text",
                    textAlign = TextAlign.Center,
                    modifier = Modifier.align(Alignment.Center)
                )
                Icon(
                    painter = painterResource(id = R.drawable.ic_launcher_background),
                    contentDescription = "Icon",
                    modifier = Modifier.align(Alignment.CenterEnd)
                )
            }

The "clicable" method can be added for all Compose layouts, for Text (lable) also.可以为所有 Compose 布局添加“clicable”方法,也可以为 Text (lable) 添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM