Using Linkify.addLinks combine with Html.fromHtml

后端 未结 3 2200
暖寄归人
暖寄归人 2021-02-14 19:16

I have a TextView that gets it\'s data set by calling this:

tv.setText(Html.fromHtml(myText));

The string myText cont

3条回答
  •  心在旅途
    2021-02-14 19:46

    You can try this one:

    First set the text in to your TextView.

    tv.setText(myText);
    

    Convert the links with Linkify

    Linkify.addLinks(tv, Linkify.ALL);
    

    and finally replace the text with Html.fromHtml but using the Linkified text from your EditText.

    tv.setText(Html.fromHtml(tv.getText().toString()));
    

提交回复
热议问题