This is a function in B4A.
Is there a way to do similar to B4J?
Is there a way to do similar to B4J?
B4X:
Public Sub ButtonSetStateListDrawable(btnBitmap As Button, EnabledBitmap As String, PressedBitmap As String, DisabledBitmap As String)
' Define a bitmap for Enabled state
Dim bdwEnabled As BitmapDrawable
bdwEnabled.Initialize(LoadBitmap(File.DirAssets, EnabledBitmap))
' Define a bitmap for Pressed state
Dim bdwPressed As BitmapDrawable
bdwPressed.Initialize(LoadBitmap(File.DirAssets, PressedBitmap))
' Define a bitmap for Disabled state
Dim bdwDisabled As BitmapDrawable
bdwDisabled.Initialize(LoadBitmap(File.DirAssets, DisabledBitmap))
' Define a StateListDrawable
Dim stdBitmap As StateListDrawable
stdBitmap.Initialize
Dim states(2) As Int
states(0) = stdBitmap.state_enabled
states(1) = -stdBitmap.state_pressed
stdBitmap.addState2(states, bdwEnabled)
Dim states(1) As Int
states(0) = stdBitmap.state_enabled
stdBitmap.addState2(states, bdwPressed)
Dim states(1) As Int
states(0) = stdBitmap.State_Disabled
stdBitmap.addState2(states, bdwDisabled)
' Set stdBitmap to button btnBitmap
btnBitmap.Background = stdBitmap
End Sub