jeudi 27 septembre 2018

i want to change the image when i click on a check box

My question is, i have one checkbox and i want, when i click first time on this check box it should change the image from my Image View and when i click again on same checkbox it should change the image in Image View with another one Image.

I Tried:-

checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if(isChecked){
                        myImage.setBackgroundResource(R.drawable.saveimage);
                    }else{
                        myImage.setBackgroundResource(R.drawable.deleteimage);
                    }
                }
            });




Aucun commentaire:

Enregistrer un commentaire