如何在android中单击单选按钮时在bindView中获取List项数据?

时间:2014-08-08 05:57:59

标签: android android-listview android-cursoradapter android-radiogroup

我的 ListItem 的人名为 e.g. ABCD RadioGroup 有两个人的 RadioButtons 即可。在bindView()点击RadioButton中的任何一个时,它应该更新名称为 ABCD 的数据。但它只更新了我的ListView中显示的lastItem。这是我的BindView():

@Override
        public void bindView(View view, Context context, Cursor cursor) {

            holder =  new  Holder();
            holder.stName = (TextView)view.findViewById(R.id.stName);
            holder.stName.setText(cursor.getString(cursor.getColumnIndex(AttendanceContentProvider.STUDENT_NAME)));

            _id_ = cursor.getString(cursor.getColumnIndex(AttendanceContentProvider._ID));
            _name_ = cursor.getString(cursor.getColumnIndex(AttendanceContentProvider.STUDENT_NAME));


            radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup1);
            radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
            {
                public void onCheckedChanged(RadioGroup group, int checkedId) {

                 ContentValues values = new ContentValues();
                    switch (checkedId) {
                    case PRESENT:
                        values.put(AttendanceContentProvider.PRESENT, checkedId);
                        break;
                    case ABSENT:
                        values.put(AttendanceContentProvider.ABSENT, checkedId);
                        break;
                    case LEAVE:
                        values.put(AttendanceContentProvider.LEAVE, checkedId);
                        break;

                    default:
                        break;
                    }

                   String where = "((" + 
                            AttendanceContentProvider._ID + " LIKE '"+_id_+"') AND (" +
                            AttendanceContentProvider.STUDENT_NAME + " LIKE '"+_name_+"') AND (" +
                            AttendanceContentProvider._ID + " NOTNULL ))";
                    getActivity().getContentResolver().update(AttendanceContentProvider.STUDENTS_URI, values, where, null);


                }
            });

        }

0 个答案:

没有答案