I have a school project where I am trying to get a flashlight app going. For the on/off ImageButton, I want to have 4 custom images.
If flashlight is off: -turn_on.png (
When setting the image using the following attribute:
android:src="@drawable/on_selector"
You will need to use the following to change the image dynamically:
ImageButton myButton = (ImageButton) findViewById(R.id.my_button); myButton.setImageResource(R.drawable.my_button_image);