我想在点击按钮后做,该按钮将变为红色并禁用,其他按钮也将禁用,这个我已经成功完成,但问题是,例如,我选择任何按钮,它显示我选中的按钮变为红色,但是当我重新打开应用程序时,第一个按钮变为红色,我的意思是例如我选择按钮5,在该页面中,它仍显示我,所有按钮禁用,按钮5将变为红色意味着我选择了按钮,但当我再次重新打开时,第一个按钮变为红色,与选择button2,button3和button4相同,下面的代码我在那里找到问题,它只能读取第一个按钮ID,我使用共享首选项。谁知道答案,请帮助我,tq,如果可以请告诉我代码。
if(getColor() != getResources().getColor(R.color.colorPrimary)) {
if(button7.isClickable()) {
button7.setBackgroundColor(getColor());
button7.setEnabled(false);
button8.setEnabled(false);
button9.setEnabled(false);
button10.setEnabled(false);
button11.setEnabled(false);
}else if(button8.isClickable()) {
button8.setBackgroundColor(getColor());
button7.setEnabled(false);
button8.setEnabled(false);
button9.setEnabled(false);
button10.setEnabled(false);
button11.setEnabled(false);
}
}