Android TextView with Clickable Links: how to capture clicks in CustomAdapter ListView?
<p>I have a <code>TextView</code> in <code>listview</code> which can have 2+ links. I had gone through to this <a href="https://stackoverflow.com/a/19989677">SO link</a> to capture the event of a <code>TextView</code> but this is not working for a list view.</p>

<p>Here is my code:</p>

<p><strong><code>getView</code> method</strong></p>

<pre><code>if(ann.message.contains("&lt;a href=")){
   setTextViewHTML(holder.announcement, ann.message);
}
</code></pre>

<p><strong>methods to make text clickable</strong></p>

<pre><code>protected void makeLinkClickable(SpannableStringBuilder strBuilder, final URLSpan span)
{
    int start = strBuilder.getSpanStart(span);
    int end = strBuilder.getSpanEnd(span);
    int flags = strBuilder.getSpanFlags(span);
    ClickableSpan clickable = new ClickableSpan() {
        public void onClick(View view) {
            // Do something with span.getURL() to handle the link click...
            Log.i("YES-5.0", span.getURL());
        }
    };
    strBuilder.setSpan(clickable, start, end, flags);
    strBuilder.removeSpan(span);
}

protected void setTextViewHTML(TextView text, String html)
{
    CharSequence sequence = Html.fromHtml(html);
    SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
    URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
    for(URLSpan span : urls) {
        makeLinkClickable(strBuilder, span);
    }
    text.setText(strBuilder);
}
</code></pre>

<p><strong>This is my <code>TextView</code>:</strong></p>

<pre><code>&lt;TextView
        android:id="@+id/textViewAnnouncementMessage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="4dp"
        android:focusable="false"
        android:textColor="@android:color/black"
        android:maxLines="5"
        android:text="@string/message"
        android:textSize="16sp"/&gt;
</code></pre>

<p>I have tried with all the combinations of following attributes of `TextView' but still no success:</p>

<pre><code>android:autoLink="all"
android:clickable="true"
android:linksClickable="true"
</code></pre>