Skip to content

Commit 6ff6f71

Browse files
committed
Updates code snippet for https://developer.android.com/quick-guides/content/support-multiple-links?hl=en (Multiple links in a text string) from deprecated pushStringAnnotation() to currently supported withLink().
1 parent 351fcb4 commit 6ff6f71

File tree

1 file changed

+15
-3
lines changed
  • compose/snippets/src/main/java/com/example/compose/snippets/text

1 file changed

+15
-3
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/text/TextSnippets.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,29 @@ private object TextEffectiveStateManagement2 {
550550
// [START android_compose_text_link_1]
551551
@Composable
552552
fun AnnotatedStringWithLinkSample() {
553-
// Display a link in the text
553+
// Display multiple links in the text
554554
Text(
555555
buildAnnotatedString {
556-
append("Build better apps faster with ")
556+
append("Go to the ")
557557
withLink(
558558
LinkAnnotation.Url(
559559
"https://developer.android.com/jetpack/compose",
560560
TextLinkStyles(style = SpanStyle(color = Color.Blue))
561561
)
562562
) {
563-
append("Jetpack Compose")
563+
append("Android Developers ")
564+
pop()
565+
append("website, and check out the")
566+
}
567+
withLink(
568+
LinkAnnotation.Url(
569+
"https://developer.android.com/jetpack/compose",
570+
TextLinkStyles(style = SpanStyle(color = Color.Green))
571+
)
572+
) {
573+
append("Compose guidance")
574+
pop()
575+
append(".")
564576
}
565577
}
566578
)

0 commit comments

Comments
 (0)