I have a text view with text" This is a product developed by XYZ. For more queries, mail us at [email protected]. And I have linkified "[email protected]". 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 [email protected] used patterns, Linkify.EMAIL_ADDRESS..nothing seem to work...kindly suggest some answers
Android Text Links Using Linkify 1 TextView AutoLinking. The TextView widget features an android:autoLink attribute that controls the types of text patterns that are automatically recognized and converted to clickable links. 2 Default Link Patterns. ... 3 Custom Link Patterns. ... 4 Match Filters. ... 5 Transform Filters. ... 6 Further Reading. ...
The Linkify class is used to create the links from the TextView or the Spannable. It converts the text and regular expression to the clickable links on the basis of the pattern match of text value and the regex.
The TextView widget features an android:autoLink attribute that controls the types of text patterns that are automatically recognized and converted to clickable links. This attribute is a convenient way to enable one or more of the default link patterns because it can be configured directly from a layout without involving any additional code.
Enabling support for one of Android’s default link patterns is very easy. Simply use the addLinks (TextView text, int mask) function and specify a mask that describes the desired link types. Detecting additional types of link patterns is easy, too.
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:[email protected]">[email protected]</a>
android:autoLink="web"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With