Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the touch events for all the views

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

like image 603
Gratzi Avatar asked Mar 24 '11 11:03

Gratzi


People also ask

What is touch slop?

Use ViewConfiguration constants "Touch slop" refers to the distance in pixels a user's touch can wander before the gesture is interpreted as scrolling. Touch slop is typically used to prevent accidental scrolling when the user is performing some other touch operation, such as touching on-screen elements.

How do I get touch event on android?

Try code below to detect touch events. mView. setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //show dialog here return false; } }); To show dialog use Activity method showDialog(int).


1 Answers

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);       }     }   } 
like image 180
peceps Avatar answered Nov 05 '22 12:11

peceps