Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable all click events of a layout?

I have a layout that contains many views. Is there an easy way to disable all its views click events?

like image 410
JustMe Avatar asked Jun 04 '11 19:06

JustMe


People also ask

How to disable click event in android studio?

I would create a ViewGroup with all the views that you want to enable/disable at the same time and call setClickable(true/false) to enable/disable clicking.

How do I disable page clicks?

Dynamically disable all clicks on pagelet freezeClic = false; // just modify that variable to disable all clics events document. addEventListener("click", e => { if (freezeClic) { e. stopPropagation(); e. preventDefault(); } }, true);

How do I turn off linear layout?

I am able to disable all content inside linear layout using following code: LinearLayout myLayout = (LinearLayout) findViewById(R. id. linearLayout1); for ( int i = 0; i < myLayout.


1 Answers

You can pass View for disable all child click event.

public static void enableDisableView(View view, boolean enabled) {         view.setEnabled(enabled);         if ( view instanceof ViewGroup ) {             ViewGroup group = (ViewGroup)view;              for ( int idx = 0 ; idx < group.getChildCount() ; idx++ ) {                 enableDisableView(group.getChildAt(idx), enabled);             }         }     } 
like image 118
Parag Chauhan Avatar answered Sep 28 '22 20:09

Parag Chauhan