我正在开发一个关于 flutter 的应用程序,我想在 android 和 ios 上禁用该平板电脑应用程序。
我有一个带RadioButton的RecyclerView我只想在同一时间选择一个RadioButton并且我的代码使它工作正常,但当我从上到下重复选择时,选择消失我怎么能修复它,谢谢.
private RadioButton lastCheckedRB = null;
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
ContactUsModel contactUsModel = orderList.get(position);
holder.orderNum.setText(contactUsModel.getOrderNum());
holder.orderCost.setText(contactUsModel.getOrderCost());
holder.radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
RadioButton checked_rb = (RadioButton) group.findViewById(checkedId);
if (lastCheckedRB != null &&lastCheckedRB.isChecked()) {
lastCheckedRB.setChecked(false);
}
//store the clicked radiobutton
lastCheckedRB = checked_rb;
}
});
Run Code Online (Sandbox Code Playgroud)