this my custom list view class whem i am scroling down our list view it's going unchecked privies select radio button
private String[] question_name;
private String[] op11, op22, op33, op44;
private Activity context;
RadioGroup rg=null;
private HashMap<Integer,String>selectitem=new HashMap<>();
public QustionAdapter(Activity context, String[] queation, String[] op1, String[] op2,
String[] op3, String[] op4) {
super(context, R.layout.qustion_custom_list, queation);
this.context = context;
this.question_name = queation;
this.op11 = op1;
this.op22 = op2;
this.op33 = op3;
this.op44 = op4;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.qustion_custom_list, null, false);
TextView questionname=(TextView)listViewItem.findViewById(R.id.qustion_tb);
RadioButton op1=(RadioButton)listViewItem.findViewById(R.id.op1);
RadioButton op2=(RadioButton)listViewItem.findViewById(R.id.op2);
RadioButton op3=(RadioButton)listViewItem.findViewById(R.id.op3);
RadioButton op4=(RadioButton)listViewItem.findViewById(R.id.op4);
rg=(RadioGroup) listViewItem.findViewById(R.id.radio_group);
// Toast.makeText(context,"Done :"+rg.getCheckedRadioButtonId(),Toast.LENGTH_LONG).show();
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Model model=new Model();
RadioButton rb=(RadioButton) group.findViewById(checkedId);
// Toast.makeText(context,"Done :"+rb.getText(),Toast.LENGTH_LONG).show();
String sel=rb.getText().toString();
selectitem.put(position,sel);
model.setSelectResult(selectitem);
}
});
questionname.setText(question_name[position]);
op1.setText(op11[position]);
op2.setText(op22[position]);
op3.setText(op33[position]);
op4.setText(op44[position]);
return listViewItem;
}'
when i select first radio group button its going select but when scroll it when i come back in radio group its goning unchecked.
here we go