Android Question Spinner text color when disabled

_marek

Member
Licensed User
Longtime User
Hello,
I noticed, that when setting text color of some views (Spinner, EditText) from code:

B4X:
MySpinner.TextColor = Colors.White

then this text color is also used when the view is disabled (instead of using faded grey color to indicate disabled state). Is there a way to set spinner text color for both enabled and disabled state? I found solution for EditText here, but does not work for Spinners:

java.lang.RuntimeException: Method: setTextColor not found in: anywheresoftware.b4a.objects.SpinnerWrapper$B4ASpinner

I also tried B4XComboBox, but it hides spinner within, so no luck there...
 

mangojack

Expert
Licensed User
Longtime User
Apparently the Spinner text color will only refresh after an Add or AddAll call.
So this is a bit of a hack solution should you not find a more direct way to achieve your goal ...

B4X:
    'Enable Spinner
    MySpinner.Add("")
    MySpinner.RemoveAt(MySpinner.Size-1)
    MySpinner.TextColor = xui.Color_White
    MySpinner.Enabled = True

    'Disable Spinner
    MySpinner.Add("")
    MySpinner.RemoveAt(MySpinner.Size-1)
    MySpinner.TextColor = xui.Color_Gray
    MySpinner.Enabled = False
 
Upvote 0
Top