i have a class:
public class custumkiemtra extends ArrayAdapter<Cauhoi>{
Context context;
int resource;
List<Cauhoi> ch;
public custumkiemtra(Context context, int resource, List<Cauhoi> ch) {
super(context, resource, ch);
this.context = context;
this.resource = resource;
this.ch = ch;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final RadioButton SDA,SDB,SDC,SDD;
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View viewrow = inflater.inflate(R.layout.custumkiemtra,parent,false);
TextView ndch = (TextView)viewrow.findViewById(R.id.cauhoi);
final Button ndA = (Button)viewrow.findViewById(R.id.DA);
final Button ndB = (Button)viewrow.findViewById(R.id.DB);
final Button ndC = (Button)viewrow.findViewById(R.id.DC);
final Button ndD = (Button)viewrow.findViewById(R.id.DD);
SDA = (RadioButton) viewrow.findViewById(R.id.SUADA);
SDB = (RadioButton) viewrow.findViewById(R.id.SUADB);
SDC = (RadioButton) viewrow.findViewById(R.id.SUADC);
SDD = (RadioButton) viewrow.findViewById(R.id.SUADD);
SDA.setEnabled(false);
SDB.setEnabled(false);
SDC.setEnabled(false);
SDD.setEnabled(false);
final Cauhoi getch = ch.get(position);
ndch.setText("Cau "+ String.valueOf(getch.get_id()) +": " + getch.getNoidung_cauhoi());
ndA.setText(getch.getNoidung_traloi1());
ndB.setText(getch.getNoidung_traloi2());
ndC.setText(getch.getNoidung_traloi3());
ndD.setText(getch.getNoidung_traloi4());
ndA.setTag(getch.get_id());
ndB.setTag(getch.get_id());
ndC.setTag(getch.get_id());
ndD.setTag(getch.get_id());
ndA.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ndA.setBackgroundResource(R.drawable.nutdapanchon);
ndB.setBackgroundResource(R.drawable.nutdapan);
ndC.setBackgroundResource(R.drawable.nutdapan);
ndD.setBackgroundResource(R.drawable.nutdapan);
SDA.setEnabled(true);
SDB.setEnabled(false);
SDC.setEnabled(false);
SDD.setEnabled(false);
}
});
return viewrow;
}
and then i use it for create a adapter for a Listview. When I click on Button NdA it'Background turn to "nutdapanchon" and SDA is "true" but then i scroll ListView and back my ndA background is back to "nutdapan" and SDA is "flase". Why? How can fix this? Help me pls?