开发者

How to custom linkify text in android

开发者 https://www.devze.com 2023-03-29 18:32 出处:网络
In my android app there is a page w开发者_StackOverflow社区here I have to display a text - \"Terms & Conditions\"

In my android app there is a page w开发者_StackOverflow社区here I have to display a text - "Terms & Conditions" On clicking this text we need to open a url in the browser Please tell me how to achieve this


May be its helpful to you.

TextView text = (TextView) findViewById(R.id.textView1);
text.settext("Your text with url");
text.setLinkTextColor(Color.BLUE); // color whatever u want
Linkify.addLinks(text, Linkify.ALL);


TextView text = (TextView) findViewById(R.id.textView1);
text.settext("Your text with url means your text value");// text having url
text.setLinkTextColor(Color.BLUE); // color whatever u want
Linkify.addLinks(text, Linkify.ALL);

Hi ankit you will set the text of yours in text view it automatically recognizes the url part of your text and creates the link to that url. if you have still any query feel free to ask :)


simple use setonItemclickListener for your textview. And in the click event create an intent to next activity which contains the webView or use default Action_VIEW which opens default browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号