How to get List item data in bindView when clicking on RadioButton in android?

萝らか妹 提交于 2019-12-18 09:49:13

问题


I have a ListItem having a person name e.g. ABCD and a RadioGroup having two RadioButtons. In my bindView() when i click any of RadioButton, it should update the data whose name is ABCD. But its only updating the lastItem shown in my ListView. Here is my 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);


                }
            });

        }

来源:https://stackoverflow.com/questions/25196894/how-to-get-list-item-data-in-bindview-when-clicking-on-radiobutton-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!