Private Sub Button1_Click
SetStatusBarColor(Rnd(0xFF000000, 0))
SetActionBarColor(Rnd(0xFF000000, 0))
End Sub
Public Sub SetActionBarColor(Color As Int)
Dim cd As ColorDrawable
cd.Initialize(Color, 0)
Dim actionbar As JavaObject = B4XPages.GetManager.ActionBar
If actionbar.IsInitialized Then
actionbar.RunMethod("setBackgroundDrawable", Array(cd))
End If
End Sub
Public Sub SetStatusBarColor(clr As Int)
Dim p As Phone
If p.SdkVersion >= 21 Then
Dim jo As JavaObject
jo.InitializeContext
Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
window.RunMethod("addFlags", Array (0x80000000))
window.RunMethod("clearFlags", Array (0x04000000))
window.RunMethod("setStatusBarColor", Array(clr))
End If
End Sub