Text(
text = "Resend OTP",
fontSize = 20.sp,
color = Textfieldcolor,
style = TextStyle(textDecoration = TextDecoration.Underline)
)
//This is my code this text should be selectable once and then be disabled .
2
Answers
Like @Arpit mentioned it would be better to use a
TextButton
for this purpose.But if you absolutely want to use
Text
, You can use following snippet.That said I this code is strictly for one-time clickable text. I won’t recommend using it for something like OTP button; as user won’t be able to click it unless they restart your app. You can pull the
enabled
variable and manage it from outside(e.g. keeping it disabled for certain amount of time rather than permanently).You can add the
clickable
modifier or can use theClickableText
: