I have created two radio buttons in a radio group dynamically and one of them is checked.
I need when i cheked another button then its value should be saved in string.
But i have implemented checkedchangelistener
for this.But its not working first time.
Here is my code.
rg = ((RadioGroup)getActivity().findViewById(alist_id.get(i)));
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
public void onCheckedChanged(RadioGroup rd, int checkedId) {
for(int i=0; i<rd.getChildCount(); i++) {
radio_button = (RadioButton) rd.getChildAt(i);
int id = radio_button.getId();
if(radio_button.getId() == checkedId) {
text = radio_button.getText().toString();
flag=true;
System.out.println("trueeeeeeeee"+text);
return;
}
}
}
});
if (flag==true) {
updated_list.add(text);
System.out.println("sssssssssssssssssss");
}else {
updated_list.add(data_from_list_view.get(i));
System.out.println("falseeeeeee");
}