Sub SetTextColorList(V As View, DefaultColor As Object, PressedColor As Object, _
DisabledColor As Object, FocusedColor As Object, FocusedDisabledColor As Object)
' Receives 5 states' colors. They can be a Boolean or a String in order to disable that state
Dim sd As StateListDrawable
Dim StateIndex As Int
Dim clrs(5) As Int
Dim states(5,2) As Int
If FocusedDisabledColor Is Int Then
clrs(StateIndex) = FocusedDisabledColor
states(StateIndex, 0) = sd.State_Disabled
states(StateIndex, 1) = 0x0101009c
StateIndex = StateIndex + 1
End If
If DisabledColor Is Int Then
clrs(StateIndex) = DisabledColor
states(StateIndex, 0) = sd.State_Disabled
StateIndex = StateIndex + 1
End If
If PressedColor Is Int Then
clrs(StateIndex) = PressedColor
states(StateIndex, 0) = sd.State_Pressed
StateIndex = StateIndex + 1
End If
If FocusedColor Is Int Then
clrs(StateIndex) = FocusedColor
states(StateIndex, 0) = 0x0101009c
StateIndex = StateIndex + 1
End If
If DefaultColor Is Int Then ' must be the last one
clrs(StateIndex) = DefaultColor
End If
Dim CSL As Object
CSL = r.CreateObject2("android.content.res.ColorStateList", Array As Object(states, clrs), Array As String("[[I", "[I"))
r.Target = V
r.RunMethod4("setTextColor", Array As Object(CSL), Array As String("android.content.res.ColorStateList"))
End Sub