iOS Question Changing images during runtime

Tom2525

Member
Licensed User
Longtime User
I would like to change imageview or button images during runtime. Is there a way to do that?
 

JonPM

Well-Known Member
Licensed User
Longtime User
For imageview you just assign new bitmap to ImageView.Bitmap.

For button:

B4X:
'state: 0 - normal, 1 - highlighted, 2 - disabled
Sub SetBackgroundImage(b As Button, bmp As Bitmap, state As Int)
Dim no As NativeObject = b
no.RunMethod("setBackgroundImage:forState:", Array(bmp, state))
End Sub
 
Upvote 0

Tom2525

Member
Licensed User
Longtime User
Never used this before as I'm new to B4A/i, but can you verify the state values? When I'm using it, the numbers seem to correspond to:

IF BUTTON DISABLED:
state: 0 - disabled, 1 - normal, 2 - highlighted

IF BUTTON ENABLED:
state: 0 - normal, 1 - disabled, 2 - disabled
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…