I have a button which switches between 2 images depending on the number of clicks...sometimes I get after leaving the activity and returning, both images show. How do make sure that only 1 image is showing?
Here is the code for the swap:
public void swapImageButton() {
swapCount ++;
if(swapCount % 2 == 0) {
mStomachImageButton.setBackground(getDrawable(image1));
mFartImageButton.setBackground(getDrawable(image2));
} else {
mStomachImageButton.setBackground(getDrawable(image2));
mFartImageButton.setBackground(getDrawable(image1));
}
}
Use a static variable for count.