I have an ImageView and i want to switch between two images in Onclick Listner For more details: in shared prefernce i have checkbox to enable and desable sound and in a layout i have an image view to handle sound in shared prefernce . this is my code :
imgsound= (ImageView)findViewById(R.id.imgsound);
imgsound.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(Settings.isSoundEnabled(getApplicationContext())){
imgsound.setImageResource(ic_sound_off);
setSoundFalse(getApplicationContext());
}
if(Settings.isSounddesabled(getApplicationContext())){
imgsound.setImageResource(ic_sound_on);
setSoundTrue(getApplicationContext());
}
}
});
the First (if-statement) work well and the image turn to ic_sound_off and sound desabled , but when i click again to enable sound and turn image to ic_sound_on dosn't work
Aucun commentaire:
Enregistrer un commentaire