Hi.
I have problem with GradientDrawable (Enabled/pressed state).
I have 5 buttons that I create at runtime.
All the buttons i set the background to a GradientDrawable.
Now when I press any of the five buttons only the last created button getting pressed visually.
If I create let say 50 buttons and scroll and push a button sometimes they all gets pressed visually and sometimes only the last one. Never the one I press (except the last one )
What's wrong? Is it a known bug?
I found the 'Gradient' code here in the forum.
I have problem with GradientDrawable (Enabled/pressed state).
I have 5 buttons that I create at runtime.
All the buttons i set the background to a GradientDrawable.
Now when I press any of the five buttons only the last created button getting pressed visually.
If I create let say 50 buttons and scroll and push a button sometimes they all gets pressed visually and sometimes only the last one. Never the one I press (except the last one )
What's wrong? Is it a known bug?
I found the 'Gradient' code here in the forum.
B4X:
'###Gradient########################
Dim colsEnabled(2) As Int
colsEnabled(0) = Colors.RGB(60, 200, 80)
colsEnabled(1) = Colors.RGB(10, 100, 20)
' Define a GradientDrawable for Enabled state
Dim gdwEnabled As GradientDrawable
gdwEnabled.Initialize("TOP_BOTTOM",colsEnabled)
gdwEnabled.CornerRadius = 5
' Define two gradient colors for Pressed state
Dim colsPressed(2) As Int
colsPressed(1) = Colors.RGB(136, 136, 136)
colsPressed(0) = Colors.RGB(0, 0, 0)
' Define a GradientDrawable for Pressed state
Dim gdwPressed As GradientDrawable
gdwPressed.Initialize("TOP_BOTTOM",colsPressed)
gdwPressed.CornerRadius = 5
' Define a StateListDrawable
Dim stdGradient As StateListDrawable
stdGradient.Initialize
Dim states(2) As Int
states(0) = stdGradient.state_enabled
states(1) = -stdGradient.state_pressed
stdGradient.addState2(states, gdwEnabled)
Dim states(1) As Int
states(0) = stdGradient.state_pressed
stdGradient.addState2(states, gdwPressed)
'###################################
For I = 1 To 5
Dim Button1 As Button
Button1.Initialize("Button1")
Button1.Text = I
Button1.Background = stdGradient
Activity.AddView(Button1, 0dip, I * 50dip, 60dip, 40dip)
Next