我有代码实现的ClickableText与下划线文本。
Row(
modifier = Modifier
.fillMaxWidth()
.height(IntrinsicSize.Min)
.padding(5.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "From",
fontWeight = FontWeight.Black
)
ClickableAddress(emailAddress = addressesFrom)
}
@Composable
fun ClickableAddress(
emailAddress: Array<EmailAddress?>
) {
for (address in emailAddress) {
address?.let { CreateUnderlineEmail(it) }?.let {
ClickableText(
text = it,
onClick = {
/*TODO*/
}
)
}
}
}
@Composable
private fun CreateUnderlineEmail(address: EmailAddress): AnnotatedString {
return buildAnnotatedString {
if (address != null) {
append(address.name + " <")
withStyle(
style = SpanStyle(
textDecoration = TextDecoration.Underline
),
) {
append(address.address)
}
append("> ")
}
}
}
我怎样才能实现与电子邮件地址列表的文本字段和每一封电子邮件必须点击?
我的代码创建的ClickableText不像行,而是作为单独的字段。
1条答案
按热度按时间n8ghc7c11#
通过addStringAnnotation找到这样的解决方案