Disable the touch events for all the views

What's the best way to disable the touch events for all the views?


Here is a function for disabling all child views of some view group:

 /**
   * Enables/Disables all child views in a view group.
   * 
   * @param viewGroup the view group
   * @param enabled <code>true</code> to enable, <code>false</code> to disable
   * the views.
   */
  public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
      View view = viewGroup.getChildAt(i);
      view.setEnabled(enabled);
      if (view instanceof ViewGroup) {
        enableDisableViewGroup((ViewGroup) view, enabled);
      }
    }
  }

Override the dispatchTouchEvent method of the activity and like this:

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

If you return true all touch events are disabled.

Return false to let them work normally