1
In a question I asked here at Stackoverflow a few days ago I was instructed to use the Expendedlistview component to represent a dynamic list of items.
After the implementation I saw that the list items were grouped correctly, but now I need to implement the return of tags and I have a new problem.
What’s happening is that my list loads perfectly, but I can’t get the Radiobuttons to behave properly, because they don’t seem to be grouped together, so it’s being possible to mark more than one item on the list. The code below shows how I’m doing to load list items in Expandedlistview and how I’m handling click:
final List<QuestoesRequest> questoes = questaoService.getListQuestoes(getIdAvaliacao());
expListView = (ExpandableListView) findViewById(R.id.expandableListView);
expListView.setAdapter(new QuestaoExpandedListAdapter(
this, questoes));
//Define um listener para tratar a selecção das respostas
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
boolean b = expListView.isItemChecked(childPosition);
RadioButton answerText = (RadioButton) v.findViewById(R.id.answerText);
answerText.setChecked(true);
//Indica que esta resposta foi seleccionada
int idQuestao = questoes.get(groupPosition).getIdQuestao();
int idAlternativa = questoes.get(groupPosition)
.getAlternativasRequests().get(childPosition).idAlternativa;
respostasQuestao.put(idQuestao, idAlternativa);
return true;
}
});
Although I can show visually the marking of Radiobutton I am not able to uncheck it, in case the choice of another option occurs.
Any suggestions? Hugs!