Reputation: 493
i am opening a website using linkify feature of android and getting %20 in my url when opening from my device so what should i do?
here is what i am doing
license=(TextView)findViewById(R.id.find_us_tv3);
license.setTextSize(18);
Pattern pattern=Pattern.compile("p"+"[page stackoverflow]+stackoverflow");
license.setText(" Open the demo page stackoverflow.");
license.setLinksClickable(true);
Linkify.addLinks(license, pattern, "http://stackoverflow.com/questions/ask");
Upvotes: 0
Views: 305
Reputation: 8134
The "http:/" in your code of
"Linkify.addLinks(license, pattern, "http:/https://stackoverflow.com/questions/ask")"
twice doesn't help.
Just use:
Pattern pattern = Pattern.compile("www.stackoverflow.com/questions/ask");
Linkify.addLinks(license, pattern, "http://");
Where the text that you mention in pattern
should be a part of the text you set in your TextView
Refer: linkify blog link
Upvotes: 2
Reputation: 4306
Try this:
TextView tvWeblink = ((TextView) findViewById(R.id.textView));
tvWeblink.setTypeface(LandingScreen.font);
tvWeblink.setClickable(true);
tvWeblink.setMovementMethod(LinkMovementMethod.getInstance());
String text = "By pressing this It will open stack overflow page <a href=\"http://stackoverflow.com/questions/ask/\"> ask a question. </a>.";
tvWeblink.setText(Html.fromHtml(text));
Upvotes: 1