I would like to have a TextView
that is both selectable and linkified. When I do both I end up with selectable text but links can\'t be clicked.
EDIT:>
The problem is in Android's TextView
. Calling Linkify.addLinks()
would not change autolinkmask in TextView
itself.
I think it's an Android bug that they check mAutoLinkMask.
So if you set android:autoLink
in xml
file, or call setAutoLinkMask()
to a non 0 value, it will work.
FYI, TextView
's source code:
if (touchIsFinished && mLinksClickable && mAutoLinkMask != 0 && textIsSelectable) {
// The LinkMovementMethod which should handle taps on links has not been installed
// on non editable text that support text selection.
// We reproduce its behavior here to open links for these.
ClickableSpan[] links = ((Spannable) mText).getSpans(getSelectionStart(),
getSelectionEnd(), ClickableSpan.class);
if (links.length > 0) {
links[0].onClick(this);
handled = true;
}
}