Using the Transform Filter

The Transform Filter gives you more freedom to format your text strings by letting you modify the implicit URI generated by the link text. Decoupling the link text from the target URI gives you more freedom in how you display data strings to your users.

To use the Transform Filter, implement the transformUrl method in your Transform Filter. When linkify finds a successful match it calls transformUrl, passing in the RegEx pattern used and the default URI string it creates. You can modify the matched string and return the URI as a target suitable to be ''viewed'' by another Android application.

The TransformFilter implementation shown in Listing 5-16 transforms the matched text into a lowercase URI.

STING 5-16: Using a Linkify Transform Filter class MyTransformFilter implements TransformFilter {

public String transformUrl(Matcher match, String url) { return url.toLowerCase();

Available for download on

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment