[英]how to retain the previously selected radio button in recycler view
This is what i have achieved by recycler view .I want to keep the previously selected radio button when this activity is launched again.这是我通过回收站视图实现的目标。我想在再次启动此活动时保留先前选择的单选按钮。 i achieved it this way.
我是这样实现的。
Override
public void onBindViewHolder(MyViewHolder holder, int position) {
DisputeIssueItem issueItem = issueItems.get(position);
holder.issue.setText(issueItem.getIssue());
holder.radioButton.setChecked(position == lastCheckedPosition);
if(previousLocation != null && position == previousLocation && position != lastCheckedPosition){
holder.radioButton.setChecked(true);
}
} but it is selecting the radio button at position 0 and I'm able to select more than one radio button like here .但它正在选择位置 0 处的单选按钮,我可以选择多个单选按钮,例如 here 。 Please suggest how will i achieve this
请建议我将如何实现这一目标
you should check the radiobutton in the radiogroup like this: radiogroup.check(IdOfYourButton)你应该像这样检查 radiogroup 中的单选按钮: radiogroup.check(IdOfYourButton)
Of course you first have to set an Id to your radiobuttons当然,您首先必须为您的单选按钮设置一个 Id
or或
set radio button true设置单选按钮为真
radio.setChecked(true); radio.setChecked(true);
@Sauda Sadaf i have same issue. @Sauda Sadaf我也有同样的问题。 have you find some solution?.
您找到解决方案了吗? if you have then plz share with me.....
如果您愿意,请与我分享.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.