Android Disable Grid Of Buttons
I have a grid with lots of buttons in it, is it possible to disable the grid which would lead to all the buttons to being disabled?. The reason why is after the use clicks a button
Solution 1:
Apparently there does not seem to be an "easy" way to solve this. What you can do is grab all buttons in your layout as an array, then loop through them. Something like the following method which disables all buttons in a GridLayout:
privatevoiddisableButtons(GridLayout layout) {
// Get all touchable viewsArrayList<View> layoutButtons = layout.getTouchables();
// loop through them, if they are an instance of Button, disable it.for(View v : layoutButtons){
if( v instanceofButton ) {
((Button)v).setEnabled(false);
}
}
}
Then simply pass in your grid layouts:
GridLayoutnumGrid= (GridLayout) findViewById(R.id.numbersGrid);
GridLayoutletterGrid= (GridLayout) findViewById(R.id.lettersGrid);
disableButtons(numGrid);
disableButtons(letterGrid);
Post a Comment for "Android Disable Grid Of Buttons"