Android Code Snippet ColorStateList as object for view properties

While working with @DonManfred 's wrap of the VectorCompat library I needed to set a ColorStateList to
a VectorDrawable ForegroundTintList property.

After fiddling around with xml files in the drawable folder I needed a more flexible way to set the foreground colors and found a snippet from @stevel05 here and modified it a little bit to use it as object.

01-10-_2016_19-59-30.jpg



B4X:
Sub GetColorStatelist(intColorPressed As Int, intColorEnabled As Int, intColorDisabled As Int) As JavaObject
    Dim States(3,1) As Int
    States(0,0) = 16842919  'Pressed
    States(1,0) = 16842910  'Enabled
    States(2,0) = -16842910 'Disabled
    Dim Color(3) As Int = Array As Int(intColorPressed, intColorEnabled, intColorDisabled)
    Dim csl As JavaObject
    csl.InitializeNewInstance("android.content.res.ColorStateList",Array As Object(States,Color))
    '
    Return csl
    '
End Sub
 
Top