在XML代码中
我有一个RelativeLayout,在那个我有一个ListView。
我正在使用布局OnClickListener

RLayout.setOnClickListener(new OnClickListener() {
//which will set an touch event for entire screen.
}


现在的问题是我的清单如下

<ListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="236dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:choiceMode="none"
    android:focusable="false"
    tools:listitem="@android:layout/simple_list_item_1" >
</ListView>


现在我的屏幕中只有一半,即ListView以外的部分正在响应OnTouchListener事件。

最佳答案

覆盖您的RelativeLayout的touchevent,并尝试将touch事件也分派到列表中。就像是:

findViewById(R.id.list).dispatchTouchEvent(event);

07-28 03:49
查看更多