Is there a good way to declare a text with a click...
# compose
a
Is there a good way to declare a text with a clickable link in Compose yet?
f
I think this should be possible using
AnnotatedString
(built using
buildAnnotatedString {}
). There is a
Text
composable overload that takes it.
a
Trying to find the api to make a part of it clickable…
f
I thought you could make
SpanStyle
clickable but maybe it is not possible after all 🤔 Sorry for misinformation 😅
Oh, do you want to whole text to be clickable? If so, you can use
ClickableText
composable.
a
I thought you could make 
SpanStyle
 clickable but maybe it is not possible after all 🤔
Sorry for misinformation 😅
Yes I meant this. Seems still not possible, I’m just using a normal text view and parses text as HTML
f
a
That looks crazy… I remember one of the goals of AnnotatedString is to be a replacement for Spans
anyway, thanks for your help!
f
No problem 🙂
a
The Android Textpert (@Siyamed) may have an update for us on this 😅
f
I think you'll have to wait a bit 😄
z
ClickableText allows you to choose which parts of the text you want to respond to clicks - the callback gets an index.
I think the goal of AnnotatedString is to replace the styling spans, but IIRC someone on the compose team said it wasn’t supposed to cover all the use cases because there would eventually be better compose apis to do some of the things you’d use spans for in the old world.
s
Copy code
<https://developer.android.com/jetpack/compose/text#click-with-annotation>
a
Thanks! I was confused how to use the pushStringAnnotation thing so it seems something that can be used with Clickable. Not sure what’s the best practice for localizing this though. I supposed I’d still have to put some marker in the string resource and figure out the start and end index from that.
u
ClickableText doesn’t seem to support Talkback a11y for text with multiple embedded links.
s
We have planned to deprecate ClickableText. We dont like it.
b/139312671 for links
🙆‍♂️ 1
b/169887606 for accessibility
🙆‍♂️ 1
u
b/169887606 for accessibility
@Siyamed I am getting
Access denied
for this ticket. Could you please get me access to it on this email: iamutkarshtiwari@mercari.com if possible 🙏
z
https://issuetracker.google.com/issues/139312671 is a different ticket but i think for the same issue
👀 1