vendredi 26 mars 2021

How Can I Make field required if checkbox is checked in Android Studio?

I would like to make a 2 Text Box field(Edit Text) required shown if a checkbox is checked and be required. I used this code Check box logic to can checked but I want after I checked 'Recycle Center' then the Text box is shown in so the user can't continue if he doesn't fill the text box. the code below:

`//CheckBox logic

    asRecycleCenter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if(compoundButton.isChecked()){
                asCustomer.setChecked(false); }
        }
    });

    asCustomer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if(compoundButton.isChecked()){
                asRecycleCenter.setChecked(false); }
        }
    });

`




Aucun commentaire:

Enregistrer un commentaire