0
A
回答
0
如果你在谈论网络,试试这个:
<p>Your text <a href="https://www.google.com" target="_blank>your link</a> some more text.</p>
在这里你可以找到关于锚标记的更多信息:https://developer.mozilla.org/en/docs/Web/HTML/Element/a
0
你能在文字之间添加标签?如果是的话根本就喜欢下面:
<a href="your url">SUV</a> are the best
如果你想linkify文本,而不在文字之间添加标签,你可以使用正则表达式来做到这一点。
请按照this url为:
1
需要使用Spannablestring和点击跨度选项以获得你需要什么。
请尝试以下解决方案。
解决方案1:
XML
<TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:textSize="24sp"
android:textColor="#234356"
android:padding="5dp"
android:id = "@+id/testview"/>
JAVA
TextView test = (TextView) findViewById(R.id.testview);
SpannableString ss = new SpannableString("SUV is the Best. Offers Avail");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
// open your browser here with the link
Intent i = new Intent(Intent.ACTION_VIEW);
i.setType("*/*");
i.setData(Uri.parse("http://www.google.com")); // your link goes here don't forget to add http://
startActivity(new Intent(Intent.createChooser(i, "Open website using")));
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
};
// 0 and 3 are the characters start and end where we need to open link on click here SUV
ss.setSpan(clickableSpan, 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
test.setText(ss);
test.setMovementMethod(LinkMovementMethod.getInstance());
test.setHighlightColor(Color.GREEN);
解决方案2:
TextView test = (TextView) findViewById(R.id.testview);
test.setText(Html.fromHtml("<a href=\"http://www.google.com\">SUV</a> <b> is the Best. Offers Avail</b> "));
test.setMovementMethod(LinkMovementMethod.getInstance());
快乐编码.. !! :)
相关问题
- 1. Windows phone7:点击按钮打开网页?
- 2. 点击如何打开另一页?
- 3. 如何在点击wordpress网站时打开pdf页面标题
- 4. 如何在InstallShield中点击按钮打开网页?
- 5. 如何通过mac-terminal打开网页时点击链接?
- 6. C#如何打开一个网页并点击一个按钮
- 7. WebView打开网页,点击链接显示“网页不可用”
- 8. 如何打开一个页面,点击模式按钮打开
- 9. 点击编辑文字打开菜单
- 10. 如何在网页中打开网页?
- 11. 点击网页推送通知时打开自定义网址
- 12. 如何打开.NET网页时在SharePoint网站点击添加新项按钮?
- 13. 点击打开文件
- 14. 如何点击超链接打开打印预览页面?
- 15. 如何在php中点击一些图片点击打开新文件点击
- 16. 如何点击带下划线的文字显示网页?
- 17. tableviewcell打开网址点击迅速
- 18. 在点击意图上打开网址
- 19. 点击ID并打开网址?
- 20. 点击div打开新鲜的页面
- 21. xamarin.forms googlemaps infowindow点击打开新页面
- 22. 按钮点击时打开页面
- 23. 打开网页
- 24. 要通过点击锚标记打开Firefox中的网页
- 25. Python 2.7 Tkinter打开网页浏览器点击
- 26. 用JavaScript模拟点击打开网页上的窗口
- 27. 打开网页并点击Android中的按钮
- 28. install4j - 点击超链接,网页浏览器不打开
- 29. Ctrl键点击无法打开链接的网页
- 30. 点击按钮后在UIWebView中打开网页