解决方案:
经过大量搜索(我已经做了,但显然还不够),我终于找到了这一页 https://stackoverflow.com/questions/7236840/android-textview-linkify-intercepts-with-parent-view-gestures.
示例代码:
我的页面(包含 listView 的 LinearLayout)分配一个 ListViewAdapter,它创建各种 ListView 项目,将自身分配为 OnClick 侦听器并添加 ListView:
list.setAdapter(adapter);
list.setOnItemClickListener(this);
addView(list);
ListViewAdapter 创建每个 ListView 项目并分配其内容,在需要时链接电子邮件地址:
public View getView(int position, View convertView, ViewGroup parent) {
View view = layoutInflater.inflate(R.layout.list_item_layout, null);
TextView textView = (TextView) view.findViewById(R.id.item_text);
textView.setText(<some email address>);
Linkify.addLinks(textView, Linkify.EMAIL_ADDRESSES);
}
解决方案很简单,使用我找到的页面上的代码。我创建了一个继承自 TextView 的 LinkTextView 类,并添加了页面上描述的方法。
在上面的 Linkify.addLinks 调用之后,我添加了以下语句:
textView.setMovementMethod(null);
ListView 项目和链接文本现在都可以再次单击。
再次,我对在提出问题之前没有进一步搜索表示最深切的歉意。