How to uncheck all the radiobuttons in radiogroup onclick of a button. What are the possible codes. Tried radiogroup.clearcheck() - Not working. My radiogroup is in listview. calling button and listview from two different layout.
On button(clear) click radiobutton should be unchecked
To view code please follow the post repeated post Thank in advance.
Change your CustomAdapter constructor from:
public CustomAdapter(Context applicationContext, String[] questionsList) {
this.context = context;
this.questionsList = questionsList;
selectedAnswers = new ArrayList<>();
for (int i = 0; i < questionsList.length; i++) {
selectedAnswers.add("3");
}
inflter = (LayoutInflater.from(applicationContext));
}
To:
public CustomAdapter(Context applicationContext, String[] questionsList) {
this.context = context;
this.questionsList = questionsList;
resetAnswers();
inflter = (LayoutInflater.from(applicationContext));
}
public void resetAnswers(){
selectedAnswers = new ArrayList<>();
for (int i = 0; i < questionsList.length; i++) {
selectedAnswers.add("3");
}
}
And inside OnClick() for Clear Button:
customAdapter.resetAnswers();
customAdapter.notifyDataSetChanged();
Hope that helps!