mardi 3 juillet 2018

Using a RecyclerView with a Checkbox

I want if the user checkmark or unchecked to make a msg display and add it to the database or to delete it.

Thank you.

@Override public void onBindViewHolder(MachineHolder holder, int position) {

    final MachinelistResponse MachineList = mData.get(position);

    holder.setNameM(MachineList.getName());
    holder.setSerialNumber(MachineList.getSerialNumber());




    MachineDB mydb = new MachineDB(Context);
    boolean Exist =mydb.isExist(MachineList.getSerialNumber());
    if (Exist== true) {
        holder.Checkbox.setChecked(true);
    } else {
        holder.Checkbox.setChecked(false);
    }

    holder.Checkbox.setOnCheckedChangeListener(null);

    holder.Checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            Toast.makeText(Context, "Select", Toast.LENGTH_SHORT).show();
        }
    });




Aucun commentaire:

Enregistrer un commentaire