例如,以下代码可以正常使用
CharSequence text = TextUtils.concat( "before ", Html.fromHtml( "<b>This works</b>"), " after " );
myTextView.setText(text, TextView.BufferType.SPANNABLE );
如果我在html代码中加了一个超链接,即
CharSequence text = TextUtils.concat( "before ", Html.fromHtml( "<a href=\"www.google.it\">Google</a>"), " after " );
myTextView.setText(text, TextView.BufferType.SPANNABLE );
Linkify.addLinks( myTextView, Linkify.ALL );
显示“Google”,但超链接未正确删除,且无法点击。有什么建议吗?
答案 0 :(得分:0)
删除第Linkify.addLinks( myTextView, Linkify.ALL );
行,并在text
和setText
声明之间放置以下一行:
classNameTextView.setMovementMethod(LinkMovementMethod.getInstance());