How to disable All buttons in a layout - Android
Unfortunately there is not an elegant way to do this (e.g. one line of simple code). However below is a method that I defined for myself that does the job perfectly:
public void disableButtons(Layout layout) { // Get all touchable views ArrayList<View> layoutButtons = layout.getTouchables(); // loop through them, if they are instances of Button, disable them. for(View v : layoutButtons){ if( v instanceof Button ) { ((Button)v).setEnabled(false); } } }
So the trick is to retrieve all touchables into an ArrayList, then loop through them while check if it is an instance of the Button class, if it is, disable it!
I'm getting a "cannot resolve" error on getTouchables()
ReplyDeletecan you explain how you did that?
You need to findViewById(). Example without error :
DeleteView rootView = findViewById(R.id.rootView);
ArrayList touchables = rootView.getTouchables();
Borgata Hotel Casino & Spa - DRMCD
ReplyDeleteBorgata Hotel Casino 목포 출장안마 & Spa, Atlantic City. 구리 출장마사지 08401 08401 08401. Website. 여수 출장마사지 https://www.borgata.com/. Address. 604 거제 출장마사지 S. Atlantic City, 거제 출장마사지 NJ 08401 08401