This is the code in my arrayadapter that will set the RadioButtons status:
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
attendance_holder holder = null;
People_Attendance people_array[] = people_attendance.toArray(new People_Attendance[people_attendance.size()]);
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new attendance_holder();
holder.txtName = (TextView)row.findViewById(R.id.name_txt);
holder.txtNumber = (TextView)row.findViewById(R.id.number_txt);
holder.attendance_group = row.findViewById(R.id.Attendance_Group);
holder.not_attending = (RadioButton) holder.attendance_group.findViewById(R.id.not_attending_radio);
holder.attending = (RadioButton) holder.attendance_group.findViewById(R.id.attending_radio);
holder.invited = (RadioButton) holder.attendance_group.findViewById(R.id.invited_radio);
row.setTag(holder);
}
else
{
holder = (attendance_holder)row.getTag();
}
holder.txtName.setText(people_array[position].name);
holder.txtNumber.setText(people_array[position].number);
if (people_array[position].attendance_status == "INVITED"){
holder.invited.setChecked(true);
}else if(people_array[position].attendance_status == "ATTENDING"){
holder.attending.setChecked(true);
}else if(people_array[position].attendance_status == "NOT ATTENDING"){
holder.not_attending.setChecked(true);
}else{
Log.d("ATTENDANCE", people_array[position].attendance_status);
}
return row;
}
I have used the Log.d() in my code to show the string, so I know it's not an empty string or bad string that's the problem. I would therefore think that either my if statements are wrong in someway, or that I am using RadioButton.setChecked() wrong. Then RadioButtons then do not get checked in the way they should do. The RadioButtons are in a RadioGroup.
Any thoughts??
Thanks for the help!!