2012-02-17 71 views
1

我需要製作帶有指向網頁鏈接的文字。我使用的代碼,但不工作:帶鏈接的字符串中的可點擊鏈接結束文字

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

回答

2

我覺得應該是...

Linkify.addLinks(licence , Linkify.WEB_URLS); 

,而不是

Linkify.addLinks(s, Linkify.WEB_URLS); 

,因爲你已經設置你的Spannable文字到您的TextView,所以請致電TextView上的addLinks ...