有时候在listView弹出对话框的时候,后面的item的onclick可以响应,我想在弹出对话框的时候不响应
public class CustomListView extends ListView {
Context mContext;
public CustomListView (Context context, AttributeSet attrs){
super(context, attrs);
mContext = context;
}
public boolean onTouchEvent(MotionEvent event){
if (event.getRawY() < 100){
Log.d("Your tag", "Allowing the touch to go to the list.");
super.onTouchEvent(event);
return true;
} else {
Log.d("Your tag", "Not allowing the touch to go to the list.");
return true;
}
}
}
<com.steve.CustomListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/start_menu_background"
android:cacheColorHint="#00000000"
android:id="@android:id/list">
</com.steve.CustomListView>
本文介绍了一种自定义ListView的方法,通过重写onTouchEvent方法来实现触摸事件的拦截。当弹出对话框时,可以阻止后续item的点击事件响应。
569

被折叠的 条评论
为什么被折叠?



