I have some TextView objects that I have onclick listeners assigned to. The onclick listeners work fine unless I run Linkify.addLinks on the TextView objects, at which point the onclick event never happens. This happens regardless of whether anything in the TextView is actually linkified. Is there a way to have both events happen, or at least be able to predict whether anything is or would be linkified in the text?
Asked
Active
Viewed 1,131 times
4
-
At this point I'm not sure there is an answer to this. I will continue to vote up any answers anyone provides here, though – atraudes Jul 11 '11 at 20:42
-
Possible duplicate of [Handle clicks on TextView's links while using Linkify for finding and setting the links inside the text](http://stackoverflow.com/questions/20242000/handle-clicks-on-textviews-links-while-using-linkify-for-finding-and-setting-th) – Oleg Filimonov Dec 06 '16 at 13:37
2 Answers
0
Linkify.addLinks()
returns a boolean which indicates if it found links in the text or not. There is no need to do a before/after comparison like Guillaume suggested.

Mike Baxter
- 6,868
- 17
- 67
- 115
0
I don't know if you found an answer or not as this question is rather old, but I just found it while looking for another problem (not exactly similar) and I can help (a bit): there is an easy way to "detect" whether Linkify modifies the text: just compares it with the original. Something like:
String originalText = textView.getText().toString();
Linkify.addLinks(textView, Linkify.ALL);
String linkifiedText = textView.getText().toString();
if (originalText.equals(linkifiedText)) {
// linkify did not do anything...
}

Guillaume
- 22,694
- 14
- 56
- 70