简体   繁体   English

如何在回收站视图中保留先前选择的单选按钮

[英]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.

相关问题 使用回收站视图时,如何取回选择了单选按钮的数据 - How to get back the data of which radio button was selected, when using recycler view 先前选择的单选按钮不起作用 - Previously selected radio button not working 如何通过单选按钮在Recycler View中调用API - How Do I call API in recycler View with the help of radio button 如何在android中的Recycler View中更改图像(如单选按钮)? - how to change image in Recycler View in android (like a radio button)? 无法在回收站视图中解决所选单选按钮拼图添加所有项目的值? - Can't solve the selected radio button puzzle in recycler view to add the value of all items? 在回收者视图中单选按钮状态未保留 - radio button state is not retaining in recycler view 在Android的“回收器”视图中的“无线电组”中选择单选按钮? - selection of radio button in Radio Group in Recycler view in android? 在回收者视图中获取所有项目中单选按钮的检查状态 - Getting the checked states of a radio button in all the items in a recycler view 在 Android Studio 中使用 Recycler View 重置单选按钮状态 - Reset Radio Button State using Recycler View in Android Studio 列表视图中的链接按钮与选定的单选按钮 - Link button with selected radio button in list view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM