我需要制作带有网页链接的文字。我使用该代码但不起作用:
licence = (TextView)findViewById(R.id.about_text5);
final SpannableString s = new SpannableString(Html.fromHtml("The ipiit Team\n\nFYI: This software contains the <a href=\"http://code.google.com/p/zxing\">zxing</a> component licensed under <a href=\"http://httpd.apache.org/docs/2.0/license.html\">Apache 2.0</a>.\n\n"));
Linkify.addLinks(s, Linkify.WEB_URLS);
licence.setText(s);
licence.setMovementMethod(LinkMovementMethod.getInstance());
答案 0 :(得分:2)
我认为应该是......
Linkify.addLinks(licence , Linkify.WEB_URLS);
而不是
Linkify.addLinks(s, Linkify.WEB_URLS);
因为您已将Spannable文本设置为TextView
,因此请在TextView
上调用addLinks ...