开发者

Android: How to create custom text for website link?

Es开发者_运维问答sentially I want to make something like http://stackoverflow.com appear as "Stack" in a checkedtextview and be a link. How can I do that?


TextView can display dumbed-down tagsoup HTML, including <a href=""/> tags. If that's in strings.xml, and you set the text using android:text, it should just happen automatically. Otherwise, you'll need to pass the html string to Html.fromHtml(). Example:

CheckedTextView ctv = (CheckedTextView) findViewById(R.id.whatever);
ctv.setText(Html.fromHtml("<a href=\"http://stackoverflow.com\">Stack</a>"));

Your layout should also set android:linksClickable="true" on the CheckedTextView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜