Top answer. Thanks for that. Now just need a neat and tidy way of passing arguments into the activity being called.
On Jul 22, 9:21 pm, Matt <[email protected]> wrote: > Yes. > > 1. Create a class which inherits ClickableSpan. See URLSpan for an > example. > 2. Your action will go into onClick() of this class. > 3. Set the text with setSpan(). > > I have an example here, although this is using a URLSpan, you would > need to change URLSpan to your custom ClickableSpan class. > > /** > * Adapted from the {...@link android.text.util.Linkify} class. > Changes > the > * first instance of {...@code link} into a HTTP link with the given > {...@code > * url}. > */ > public static void linkify(TextView view, final String link, > final String url) > { > CharSequence text = view.getText(); > String string = text.toString(); > > URLSpan span = new URLSpan(url); > int start = string.indexOf(link); > int end = start + link.length(); > > if (start == -1) > return; > > if (text instanceof Spannable) > { > ((Spannable) text).setSpan(span, start, end, > Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); > } > else > { > SpannableString s = SpannableString.valueOf(text); > s.setSpan(span, start, end, > Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); > view.setText(s); > } > > // Adapted from Linkify.addLinkMovementMethod(), to make links > clickable > // > MovementMethod m = view.getMovementMethod(); > if ((m == null) || !(m instanceof LinkMovementMethod)) > { > > view.setMovementMethod(LinkMovementMethod.getInstance()); > } > } > > On Jul 22, 3:13 pm, "[email protected]" > > > > <[email protected]> wrote: > > Dear all, > > I'm not sure if this can be done, but is it possible to > > launch an activity from text that has been Linkified? I'm basically > > providing an illustrated glossary, and when the user clicks on a > > highlighted term, I want the activity that handles display of the > > image and associated text to fire up. I also need to pass in some > > parameters to the activity being launched. > > > Thanks for any help > > > Angus -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

