Set dispatchTouchEvent for List View without creating custom List View class. (for disabling scroll)

喜你入骨 提交于 2020-01-05 07:08:23

问题


I'm basically trying to disable the scroll on List View. Which can be done by

@Override
    public boolean dispatchTouchEvent(MotionEvent ev){
       if(ev.getAction()==MotionEvent.ACTION_MOVE){
            ev.setAction(MotionEvent.ACTION_CANCEL);
       }

       super.dispatchTouchEvent(ev);
       return true;
    }

But I do not want to create a custom List View (widget) class for this.

Is there any way I could do it like myListView.dispatchTouchEvent(ev)???

Thanks in advance.


回答1:


Give this a try:

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
   return true;
}


来源:https://stackoverflow.com/questions/11401164/set-dispatchtouchevent-for-list-view-without-creating-custom-list-view-class-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!