开发者

Linkify in android TextView

开发者 https://www.devze.com 2023-02-12 09:29 出处:网络
I have a text view with text\" This is a product developed by XYZ. For more queries, mail us at info@abc.com. And I have linkified \"info@abc.com\".开发者_Python百科 But the problem is, whenever I tou

I have a text view with text" This is a product developed by XYZ. For more queries, mail us at info@abc.com. And I have linkified "info@abc.com".开发者_Python百科 But the problem is, whenever I touch any area below the textview, it gets linked to the email. How Do I make sure, the link has to happen only on clicking info@....I used patterns, Linkify.EMAIL_ADDRESS..nothing seem to work...kindly suggest some answers


I had problems with automatic links, so I turned it off and instead I am using html formating of the text plus this code:

TextView textView = (TextView) findViewById(R.id.TextBox);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(Html.fromHtml(strText));

An email link goes <a href="mailto:my@email.com">my@email.com</a>


 android:autoLink="web"


Try using HTML formatting i.e. anchor tag for the link.


Method using Linkify Class:

myTextView.setAutoLinkMask(Linkify.EMAIL_ADDRESSES);
myTextView.setLinksClickable(true);
0

精彩评论

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