如何在Android中保存複選框狀態。 條件:如果選中複選框,則單選按鈕必須爲雙拼,反之亦然。如何使用SharedPreferences在Android中保存狀態?
//More like an enable-disable button which should save
radioButtons states and then disable/enable them
//RadioButtons states should be saved too
//if radioeg1 was checked when checkbox was checked, its state should
be saved
Eg.
// cb = (Checkbox) findViewById(...)
//radioeg1 = (RadioButton) findViewById(...)
//radioeg2 = (RadioButton) findViewById(...)
if (cb.ischecked){
//save cb state as checked
//radioeg1.setEnabled(false) must be saved
//radioeg2.setEnabled(false) must be saved
//change the RadioButtons textcolor to grey? //Optional but an added Bonus if possible
//if not possible using this way, maybe change a textview's color to grey?
}
最好爲代碼提供解釋! – Sweeper
我是新來的概念,你能提供一個解釋嗎?我需要用什麼來代替「背景」? –