Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linkify in android TextView

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

like image 978
Rashmi.B Avatar asked Feb 18 '11 14:02

Rashmi.B


People also ask

How to create text links in Android using linkify?

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. ...

How to create links from textview or spannable?

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.

What is the AutoLink attribute in textview?

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.

How do I add a link pattern to a textview?

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.


2 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:[email protected]">[email protected]</a>

like image 115
Lumis Avatar answered Sep 24 '22 23:09

Lumis


 android:autoLink="web"
like image 25
Rohit Mandiwal Avatar answered Sep 23 '22 23:09

Rohit Mandiwal