URL of android view in XML layout

I have a layout that I installed with an xroid layout. I would like to insert a link in a text view so that by clicking on the link it opens in the Android browser. how it's done. There seems to be no url or anything else.

+3
source share
2 answers

You just need to specify the URL in TextView and then Linkify . There is also a tutorial on Linkify and custom links that can help.

+4
source

, . , blammo . blammo, google.com.

- :

class sampleTransformFilter implements TransformFilter {
    public String transformUrl(Matcher match, String url) {
        return "http://google.com";
    }
}

class sampleMatchFilter implements MatchFilter {
    public boolean acceptMatch(CharSequence s, int start, int end) {
        return true;
    }
}       

Pattern sampleMatcher = Pattern.compile("blammo");      
String sampleURL =    "";
Linkify.addLinks(textView, sampleMatcher, sampleURL, new sampleMatchFilter(), new sampleTransformFilter());
+2

Source: https://habr.com/ru/post/1730153/


All Articles