我为列表视图编写了定制的项目布局.布局中有许多小部件,有些将具有自己的clicklistener.
当我单击该行时,有时listview的onListItemClick起作用,但有时不起作用.
经过一段时间的搜索后,我找到了一种方法,可以在布局的根目录中设置android:descendantFocusability =“ blocksDescendants”.它可以工作,但是只有一个textview不能工作(已尝试了可单击,可折叠的属性).在列表的适配器中,我设置了textview的onClickListener,它可以工作.但这不是自然,有人知道如何解决吗?
顺便说一句,有没有办法区分不同的小部件的点击?现在,无论我单击什么(除textview之外),整行的背景选择器都已更改.
非常感谢!
//我的列表行布局根
android:descendantFocusability="blocksDescendants"
android:padding="@dimen/medium"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
//糟糕的textview
android:id="@+id/text"
android:textColor="@android:color/secondary_text_light"
android:textColorLink="@android:color/holo_blue_dark"
android:layout_marginTop="@dimen/small"
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
android:layout_below="@id/nick"
android:layout_alignLeft="@id/nick"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
更新
textview使用Linkify提供一些链接功能.