How to make links in a TextView clickable?

后端 未结 30 3267

I have the following TextView defined:



        
30条回答
  •  抹茶落季
    2020-11-22 00:05

    The easiest thing that worked for me is to use Linkify

    TextView txt_Message = (TextView) view.findViewById(R.id.txt_message);
    txt_Message.setText("This is link https://www.google.co.in/");
    Linkify.addLinks(txt_Message, Linkify.WEB_URLS);
    

    and it will automatically detect the web urls from the text in the textview.

提交回复
热议问题