超链接在安卓 [英] Hyperlink in Android
问题描述
我有一个问题:我怎么可以把一个超级链接在正常文本的文本块?我有一些文字,并在文中我提到一个网址,我想在一个不同的颜色这个URL,下划线和点击的。
I have a question: How can I place a hyperlink WITHIN a text-block of normal text? I have some text and in the text I mention a URL and I want this URL to be in a different color, underlined and click-able.
我知道Android的超链接,可以放置Linkify.. 和我提到安卓文档页
I know hyperlinks in android can be placed with "Linkify".. and i have referred android docs page
考虑使用Android的文档我想在Android中显示相同的上段.....
推荐答案
@Fedor .... 我发现给从<一个链接href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/text/Link.html"> API演示的。
@Fedor.... i have found to give links from API Demos .
这种方法最终被用于给连接在段文字之间。
this approach is finally be used for giving link in between text of paragraph.
SpannableString ss = new SpannableString("text4: Click here
to dial the phone.");
ss.setSpan(new StyleSpan(Typeface.ITALIC), 0, 6,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView t4 = (TextView) findViewById(R.id.TextView01);
t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());
这篇关于超链接在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!