I am creating two radio buttons in a radio group programmatically.But both buttons are checked when i click on both.I mean not following the radio buttons property.I have two options YES and NO.And i need to get one checked at a time not both. my code is below...thanks in advance
public static void YesNoQuestion(Context context , View v,Question_Bean ques ,int ParentView){
LinearLayout linearLayout = (LinearLayout) v.findViewById(ParentView);
LayoutParams lp = new LayoutParams ( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
TextView question = new TextView(context);
question.setText(ques.getQuestion());
question.setTag(ques.getQid());
RadioGroup rgroup = new RadioGroup(context);
rgroup.setOrientation(RadioGroup.VERTICAL);
RadioButton optionYes = new RadioButton(context);
optionYes.setText(" Yes ");
RadioButton optionNo = new RadioButton(context);
optionNo.setText(" No ");
rgroup.addView(optionYes,lp);
rgroup.addView(optionNo,lp);
linearLayout.addView(question,lp);
linearLayout.addView(rgroup,lp);
}