How can I disable all views inside the layout?

后端 未结 23 1351
一个人的身影
一个人的身影 2020-11-28 08:46

For example I have:



        
23条回答
  •  暖寄归人
    2020-11-28 09:30

    If you want to disable a set of, or say a particular kind of view.Let's say you want to disable a fixed number of buttons with some particular text of or no text then you can use array of that type and loop through the array elements while disabling the buttons using setEnabled(false) property You can do it on a function call like this:

    public void disable(){
            for(int i=0;i<9;i++){
                    if(bt[i].getText().equals("")){//Button Text condition
                        bt[i].setEnabled(false);
                }
            }
    }
    

提交回复
热议问题