Hey there.
Well let's google and try to find a solution I will type.
Android how to change image to another.
And back
and one of the first is the side stack overflow which are told you about it says here.
Use the Image view on click method to change the image back and forth.
That is it looks like what we need.
Click on this link.
Let's see.
Here it is written that this code does not work.
And here below is the answer which says I'm not sure what you are asking but if you want to change images
back and forth using on click then you can try to change the modify code which I wrote below.
This code is written here.
Variable type boolean first image shown is used here.
This variable boolean is set to true initially let me explain.
In our example how this works.
We need to create the so-called flag flag.
Is there boolean value that is said either true or false and dependent on different conditions.
Let's name our flag boolean is Tom visible
and assign this variable the value.
True initially the name of this variable translate translates as equation is the tone visible now and
the value is true because Tom's image is originally let's see.
As you can see Alpha is not specified but by default the alpha attribute is equals to one that is Tom
is visible.
Therefore we said this flag to true.
And here in the areas Tom method we check the variable we write Eve is Tom visible.
That is if the cat image is visible then we are executing this code that we had.
That is we erase the cat and the mouse appears and out.
We do this we said all a variable and is strong visible false because Tom is no longer visible.
He disappeared.
We arrived here is Tom visible.
False
further.
In another case when Tom is no longer visible we can insert the same code not only here we will change
everything the other way around this part of the code will be executed.
If a storm visible is false since Tom is not reasonable we need to said that all up to one that is make
it appear and Jerry needs.
On the contrary said alpha to 0 2 Make it disappear.
And again is Tom visible is true now because the cat has become visible again.
Well let's try what we got
and so click on the cat and mouse appears.
Click on Jerry.
Tom appears once again on Tom Jerry appears cool.