Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
首先,我想将切换按钮的状态从 false 更改为 true,然后如果它为 true,我想禁用切换按钮,这样任何人都无法再次更改它。请帮助我,因为我是 android 新手。
你可以这样做,
//get the button as ToggleButton tb = (ToggleButton) findViewById(R.id.togglebutton1); // check it is enabled if(tb.isChecked()){ //do something on enabling it tb.setEnabled(false); // disable it }