views:

293

answers:

2

I have a problem with TextView and autoLink feature.

I have an about screen in my application with some information like support phone number, email address, website URL and application version in form like 01.01.01

After setting autoLink="all" on the textView, all values are linked fine - except that version number 01.01.01 is linked as the phone number as well.

Is there some way to exclude this text fragment from linkifing?

+1  A: 

Place version to another TextView?

Fedor
+1  A: 

Just don't use autoLink, linkify text from your code. It's quite easy using Linkify class.

private static final String phoneRegex="123\.456\.789";//you can just place your support phone here
private static final Pattern phoneMatcher = Pattern.compile(phoneRegex);

public static void linkify(TextView text){
    Linkify.addLinks(text, Linkify.EMAIL_ADDRESSES);
    Linkify.addLinks(text, Linkify.WEB_URLS);
    Linkify.addLinks(text, phoneMatcher, "tel:");
}

You don't need to modify url and email expression. But you should specify your own expression for phone. And it doesn't need to be an expression that matches all phones. It just needs to match your specific support phone.

Fedor