I have a standard LinkMovementMethod
established in my TextView
to push a web Activity of some sort when the user touches a link. However, I want to establish a "do you want to see the link" dialog rather than taking the user straight to the webpage. I've tried overriding the touch methods but it all gets a little convoluted. A little help?
You can accomplish it in two ways:
LinkMovementMethod
to accept custom click listenerIn my opinion second solution is better in basic cases like yours. Here is how you can do it:
OnLinkClickedListener clickListener = new OnLinkClickedListener() {
@Override
public boolean onLinkClicked(String linkText) {
// here you can handle your click, eg show the dialog
// `linkText` is the text being clicked (the link)
// return true if handled, false otherwise
}
}
yourTextView.setMovementMethod(new InternalLinkMovementMethod(clickListener));