views:

23

answers:

1

Hello there,

I'm working with a CheckBox that needs to hace some links appearing as text, not urls. I'm using something like this:

        TransformFilter transformer = new TransformFilter() {
        @Override
        public String transformUrl(Matcher match, String url) {
            Log.d("                ", match.toString() + " ||||| " + url);

            return url.substring(1, url.length() - 1);
        }
    };

    Linkify.addLinks(acceptCheckbox, Pattern.compile("\\(.*?\\)"), null, null, transformer);

If I understand well, if the text in the checkbox contains "(something here)" it should output "something here" without parentheses.

This is just a test before adding the link ie. (go to google-http://www.google.com)

The thing is the links look like links but they are not modified (still with parentheses). Even if I put a schema or I hardcode the String in transformUrl method nothing happens.

I tried with setting autoLink to none, setAutoLinkMask(0), and maybe some more but still stuck. Any idea?

Thanks

A: 

I finally ended up using html code in the android:text attribute on the Checkbox.

Just be careful if you are saving the html code in strings.xml, you must escape entities:

<a href="http://www.google.com"&gt;Visit Google</a>

&lt;a href=\"http://www.google.com\"&amp;gt;Visit Google&lt;/a&gt;

Regards

momo