Dim r As Reflector
r.Target = SimpleExoPlayerView1
Dim controller As B4XView = r.GetField("controller")
controller.GetView(0).Color = xui.Color_Green
For Each v As B4XView In controller.GetAllViewsRecursive
If GetType(v) = "android.widget.ImageButton" Then
SetColors(v, xui.Color_Red, xui.Color_Yellow)
End If
Next
Sub SetColors (v As B4XView, On As Int, Off As Int)
Dim DrawableCompat As JavaObject
DrawableCompat.InitializeStatic("android.support.v4.graphics.drawable.DrawableCompat")
Dim drawable As JavaObject = DrawableCompat.RunMethod("wrap", Array(v.As(JavaObject).RunMethod("getDrawable", Null)))
If drawable.IsInitialized = False Then
Return
End If
DrawableCompat.RunMethod("setTintList", Array(drawable.RunMethod("mutate", Null), CreateColorStateList(On, Off)))
v.As(JavaObject).RunMethod("setImageDrawable", Array(drawable))
End Sub
'Based on: https://www.b4x.com/android/forum/threads/colorstatelist.40788/#content
Sub CreateColorStateList(On As Int,Off As Int) As Object
Dim sd As StateListDrawable 'ignore
Dim States(2,1) As Int
States(0,0) = sd.State_Checked
States(1,0) = sd.State_Enabled
Dim CSL As JavaObject
CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States, Array As Int(On, Off)))
Return CSL
End Sub