Autolink inside a TextView in android

前端 未结 5 1974
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 02:57

How to give autolink for some part of textview ? For example : My text inside TextView is \"Please click here to open this webpage\". I want to show link for only the text \

5条回答
  •  无人及你
    2020-12-14 03:15

    Use HTML syntax in strings.xml:

    Click <a href="http://vtuhtan.info">here</a>
    

    Set TextView properties to have links clickable and auto link.

    TextView tv = findViewById(R.id.textView);
    tv.setText(Html.fromHtml(getResources().getString(R.string.test)));
    

提交回复
热议问题