mardi 7 août 2018

how to add and remove values from arraylist when checkbox is check and unchecked

holder.mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { myPosition.setSelected(isChecked); int id = buttonView.getId();

            if (buttonView.isChecked()) {
                productId = measuremntTypeList.getResults().get(listPosition).getProductId();
                measurementId = measuremntTypeList.getResults().get(listPosition)
                        .getMeasurementTypeId();
                measurementName = measuremntTypeList.getResults().get(listPosition)
                        .getMeasurementTypeName();
                isSelected = true;
                test.add(new MeasurementTypeModel(productId, measurementId,
                        measurementName, isSelected));
                mCallback.test(test);
                Log.e("check", "" + test.size());
            } else {
                test.remove(new MeasurementTypeModel(productId, measurementId,
                        measurementName, isSelected));

// mCallback.test(test.remove(new MeasurementTypeModel(productId, measurementId, measurementName, isSelected))); mCallback.test(test); Log.e("checkout", "" + test.size());

// }




Aucun commentaire:

Enregistrer un commentaire