我有一个RadioGroup,有2个RadioButtons,男性和女性。我存储他们的价值观
SharedPreferences.Editor editor = getSharedPreferences(preferences, MODE_PRIVATE).edit();
rButton=(RadioButton) findViewById(rGroup.getCheckedRadioButtonId());
editor.putString("gender",rButton.getText()+"");
并像这样加载它们
SharedPreferences editor = getSharedPreferences(preferences, MODE_PRIVATE);
String toast=editor.getString("gender","Male")+"";
if (toast.equals("Female")){rGroup.check(R.id.radioButton2);}
else{rGroup.check(R.id.radioButton);}
然而,这似乎是一种保存和存储它们的奇怪方式。有没有更好的方法呢? Android store radiogroup id in sharedpreferences and load it 更改代码或其他内容后,视图是否可以更改其ID号?