我需要制作带有网页链接的文本。我使用该代码,但无法正常工作:

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());

最佳答案

我认为应该...

Linkify.addLinks(licence , Linkify.WEB_URLS);


并不是

Linkify.addLinks(s, Linkify.WEB_URLS);


因为您已经将可扩展文本设置为TextView,所以请在TextView上调用addLinks ...

10-04 14:52