I populated a list of questions and answers with ListView.
Each question has 6 options(single selection); if I select any option, the previously selected option should be invalidated.
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
View views = convertView;
views = inflater.inflate(R.layout.row_question_list, null);
holder = new ViewHolders();
holder.titleQuestion = (TextView)views.findViewById(R.id.tv_quetion_label);
holder.c_option1 = (TextView)views.findViewById(R.id.question);
holder.ibOption1= (ImageButton)views.findViewById(R.id.ibOption1);
holder.ibOption2= (ImageButton)views.findViewById(R.id.ibOption2);
holder.ibOption3= (ImageButton)views.findViewById(R.id.ibOption3);
holder.ibOption4 = (ImageButton)views.findViewById(R.id.ibOption4);
holder.ibOption5 = (ImageButton)views.findViewById(R.id.ibOption5);
holder.ibOption6 = (ImageButton)views.findViewById(R.id.ibOption6);
holder.ibOption6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Need to select current selection and invalide previous selection.
// For current selection
((ImageButton) view).setSelected(type);
}
});
return views;
}
How to get the views of the other options?