创建应用程序,其中我在recyclerview列表中设置数据,并在radiogroup和text中使用radiobutton显示数据。我能够检查radiobutton,但是当我再次打开该活动时,我检查的radiobutton未经检查,但我希望当我再次开放活动,我的无线电话应该被检查。
这是我的Adapter类:
holder.radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton checked_rb = (RadioButton) group.findViewById(checkedId);
holder.radioButton.setChecked(true);
if (lastCheckedRB != null) {
lastCheckedRB.setChecked(false);
}
if(selectedId!=0)
{
holder.radioButton.setChecked(true);
}
//store the clicked radiobutton
if(holder.radioButton.isChecked())
{
teamList.clear();
lastCheckedRB = checked_rb;
teamList.add(name);
int checkedIndex = group.indexOfChild(checked_rb);
}
else
{
holder.radioButton.setChecked(false);
}
int selectedId = holder.radioGroup.getCheckedRadioButtonId();
}
这是我的Activity类:
protected void onResume() {
super.onResume();
try {
adapter.lastCheckedRB.setChecked(true);
}
adapter.notifyDataSetChanged();
} catch (NullPointerException e) {
}
}
答案 0 :(得分:0)