Make Hyperlink in Textview android -
i want make hyperlink "terms" , "privacy policy" not working in case:-
mtermspptext = (textview) view.findviewbyid(r.id.bottom_text); string value = "<html>by joining agree our <font color=\"#3c599f\" ><a href=\"http://www.google.com/\">terms</a></font> & <font color=\"#3c599f\" ><a href=\"http://www.google.com/\">privacy policy</a></font></html>"; mtermspptext.settext(value);
please use spannable string string below:
string value = "<html>by joining agree our <font color=\"#3c599f\" ><a href=\"http://www.google.com/\">terms</a></font> & <font color=\"#3c599f\" ><a href=\"http://www.google.com/\">privacy policy</a></font></html>"; spannable s = (spannable) html.fromhtml(value); urlspan[] spans = s.getspans(0, s.length(), urlspan.class); (urlspan span: spans) { int start = s.getspanstart(span); int end = s.getspanend(span); s.removespan(span); span = new urlspan(span.geturl()); s.setspan(span, start, end, 0); } mtermspptext.settext(s); use movement method performing operation on click
mtermspptext.setmovementmethod(linkmovementmethod.getinstance()); hope helpfull you.
Comments
Post a Comment