3

我开发了一个 Thread BBS 应用程序。我将 ListView 用于线程。ListView 有一些 TextView,而 TextView 有一些 Clickable URLSpan。


textview1 我的名字

textview2 消息消息消息。正文http://google.co.jp/ 正文消息消息消息。


我想在下面采取行动,但我不能。

当我点击除 urlspan(link) 之外的行时,发生了 onListItemClick 事件。当我点击 urlspan 时,没有发生 onListItemClick 事件,并且发生了 URLSpan 的 OnClick 事件。

我在 ArrayAdapter 为 ListView 编写以下代码。

Spanned html = Html.fromHtml(body, new EmojiGetter(mContext), null);
SpannableString spannable = new SpannableString(html);
Pattern p = Pattern.compile("(http://google.co.jp/)");
Matcher m = p.matcher(spannable);
while(m.find()){
    MyUrlSpan myUrlSpan = new MyUrlSpan("http://google.co.jp/", m.group(1));
    spannable.setSpan(myUrlSpan, m.start(1), m.end(1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
holder.body.setText(spannable, TextView.BufferType.SPANNABLE);
holder.body.setMovementMethod(LinkMovementMethod.getInstance());
holder.body.setFocusable(false);
holder.body.setFocusableInTouchMode(false);

但是当我点击 textview2 时,没有发生 onListItemClick 事件。

我怎样才能意识到这个动作?

4

0 回答 0