I have developed a dynamic UI of survey questions, where I have questions answering "YES" or "NO". For questions having answers as Yes/No, I have taken radio-group for user input. How to change the color of the Radio button Highlight color for a specific question , when a specific radioGroup option(Yes/no) is selected everytime? I have Done the following implementation, but it is not working.
final AppCompatRadioButton[] rb = new AppCompatRadioButton[2];
final RadioGroup rg = new RadioGroup(context); //create the RadioGroup
rg.setOrientation(RadioGroup.HORIZONTAL);//or RadioGroup.VERTICAL
String[] options = context.getResources().getStringArray(R.array.radio_options_yes_no);
if (questionList.get(j).getQuestionId().matches("3|16|24"))
{
rb[0].setHighlightColor(context.getResources().getColor(R.color.red));
rb[0].setTextColor(context.getResources().getColor(R.color.red));
}
//for yes as unsafe option
else if (questionList.get(j).getQuestionId().matches("21|23|30|32")){
rb[1].setHighlightColor(context.getResources().getColor(R.color.red));
rb[1].setTextColor(context.getResources().getColor(R.color.red));
}