I have a layout that contains many views. Is there an easy way to disable all its views click events?
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.
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);
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.
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); } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With