My application has a GridView. It already has a onItemClickListener and onItemLongClickListener. I would like to disable the scrolling in the GridView now. With the help of https://stackoverflow.com/a/6496632/985025 I have added an onTouchListener as shown below:
mGridView.setOnItemClickListener(this);
mGridView.setOnItemLongClickListener(this);
mGridView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
if(arg1.getAction() == MotionEvent.ACTION_MOVE)
return true;
else
return false;
}
});
My expected behavior is that when ever I try to scroll in the GridView, that event should be ignored. But, I get an event in onItemClick even after returning true in onTouch. Is there a way to avoid onItemClick in case of scroll on GridView?