Changing between pictures?

baron159

Member
Licensed User
Longtime User
The :sign0104: here again,
I am making a program that needs the buttons to change between many bitmap images, i have change the first image to the right one but i need it to change when a certain event happens....what is the code i need to do that....

for this example use
button1 as button
pic1.bit as original image
pic2.bit as image i need to change too
......
am i missing anything else that i need to dim?
......
but what would the code look like to change button from pic1 to pic2?
 

klaus

Expert
Licensed User
Longtime User
Something like this, with the image file in the Files Tab:
B4X:
Dim bmd As BitmaDrawable
bmd.Initialize(LoadBitmap(File.DirAssets, "pic2.png"))
button.Background = bmd
or with a bitmap already initialized:
B4X:
Dim pic2 as Bitmap
pic2.Initialize(LoadBitmap(File.DirAssets, "pic2.png"))
.
.
Dim bmd As BitmaDrawable
bmd.Initialize(pic2)
button.Background = bmd
Best regards.
 
Top