Android Question How to change color of "ComboBox" or "Spinner" drop down arrow?

vhd_bgh

Member
Untitled.png

How to change color of ComboBox or Spinner arrow?
There is nothing in this specification
 
B4X:
Dim jo As JavaObject = Spinner1.Background
jo.RunMethod("setColorFilter", Array(xui.Color_Red, "SRC_ATOP"))
Hi Erel,
in the Android Developer documentation they say that the "setColorFilter" method used in your example is deprecated in API 29.
I tried implementing the other method cited in the list but it doesn't seem to work.
I tried to follow the documentation instructions and some examples I found like this.

Here's my code:
B4X:
Dim jo1 As JavaObject = mySpinner.Background
Dim p As Phone
If p.SdkVersion < 29 Then
    jo.RunMethod("setColorFilter", Array(mySpinner.TextColor, "SRC_ATOP"))
Else
    Dim jo2 As JavaObject
    jo2 = jo2.InitializeNewInstance("android.graphics.BlendModeColorFilter", Array(mySpinner.TextColor, "SRC_ATOP"))
    jo.RunMethod("setColorFilter", Array(jo2))
End If

Is there a way to get this working in devices with API > 28?
 
Upvote 0
Hi Erel, thank you for your answer.

In these hours I did some tests on an API 30 device and, as you suggested, the deprecated method still worked fine on a sample project (but not in my main one).
So I figured that the broblem wasn't the deprecated method but something else in my project.

Only after quite some time I figured that the problem was that I was showing and hiding some panels behind my spinner and, for some reason, the "setColorFilter" method did not work as expected (Samsung Galaxy Tab A7 Lite, API 30).
At the end I managed to get it to work by adding the spinner (and a label) to a different panel instead of the same panel that has the background panels.

Still this is a strange behavior because the I don't think that the same app installed in two different devices should behave differently:

This is the example project running in a Wiko Lenny 3 (API 23)This is the example project running in the Galaxy Tab A7 Lite (API 30)
20220224_170157 00_00_00-00_00_30.gif
20220224_164516 00_00_00-00_00_30.gif

You can find the example project attached.

At the end I fixed the problem that I had in my project, but at the same time I found out other things that I don't know how to explain.
 

Attachments

  • prova.zip
    16.3 KB · Views: 189
Upvote 0
Top