Android: Change image on button click

This little android example will show you how to change the image of an image view trough a button click. For this we have two images in our drawable folder:


We define an image view in activity_main.xml and two buttons for switching on/off the brain:

Now we need to implement the code in the like this:


This is the main part changing the image:



Source download:

About The Author

Related posts

To post sourcecode please use <code>..</code> tags.

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar