且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单击 ListView 的列表项没有响应

更新时间:2023-12-05 16:32:58

您应该在项目列表视图(TextView、ImageView 等)中定义所有子对象:

You should define on all of the child objects in the item listview (TextView, ImageView etc.):

android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"

对于根项RelativeLayout/LinearLayout等,定义:

And for the root item RelativeLayout / LinearLayout and so, define:

android:clickable="false"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:focusableInTouchMode="false"

如果您不定义这些,它们将捕获"点击事件.如果您有自定义 listView 适配器,只需检查您是否覆盖:

If you won't define those, they will "catch" the click event. And if you have a Custom listView adapter, just check that you override:

@Override
public boolean isEnabled(int position)
{
    return true;
}