All,
I have the below Listview with a radiogroup. I'm trying to save this info into a sqlite table. Below is the listview with radiogroup and I'm also showing my ListAdapter. Not sure what I'm doing wrong below. Where should I place the code to store the positions and save to sql table?? Thanks.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View v = convertView;
final ViewHolder holder;
if(v == null) {
v = mInflater.inflate(R.layout.list_item_cars, parent, false);
holder = new ViewHolder();
holder.txtCarName = (TextView) v.findViewById(R.id.txt_car_name);
holder.radioGroup = (RadioGroup) convertView.findViewById(R.id.condition);
holder.radioGroup.setTag(position);
v.setTag(holder);
}
else {
holder = (ViewHolder) v.getTag();
}
// fill row data
final Car currentItem = getItem(position);
if(currentItem != null) {
holder.txtCarName.setText(currentItem.getCar());
}
holder.radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
List<Integer> x = new ArrayList<Integer>();
public void onCheckedChanged(RadioGroup group, int checkedId) {
x.add(Integer.parseInt(group.getTag().toString()), checkedId);
int getPosition = (Integer) group.getTag();
notifyDataSetChanged();
}
});
return v;
}
Aucun commentaire:
Enregistrer un commentaire