How to make links in a TextView clickable?

后端 未结 30 3831

I have the following TextView defined:



        
30条回答
  •  轮回少年
    2020-11-21 23:54

    This is how I solved clickable and Visible links in a TextView (by code)

    private void setAsLink(TextView view, String url){
            Pattern pattern = Pattern.compile(url);
            Linkify.addLinks(view, pattern, "http://");
            view.setText(Html.fromHtml("http://"+url+""));
        }
    

提交回复
热议问题