Android Question B4X Combo Box - And Standard Spinner Color change flaky

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I wish to change a B4XComboBox text color from black to red to indicate to the user that the field has been changed by the user.

I do this by responding to the _SelectedIndexChanged event, However if I change the field once the changed is picked up by the listener and the _SelectedIndexChanged is called, however the color doesn't change. If I make another change to the combo selection the change calls the _SelectedIndexChanged and the color DOES change.

I thought maybe it had something to do with asynch events, but putting in sleep(0)'s didn't fix the problem.

I have attached simple example that exhibits this behaviour for both the B4X Combo and standard.

I guess the B4X box is a wrapper around the standard spinner so I think the problem is with the spinner

Main Program:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region


'======================================================================================================
Sub Process_Globals

End Sub

'======================================================================================================
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private acSpinPlantMonth As B4XComboBox
    Private acSpinHarvestMonth As Spinner
End Sub

'======================================================================================================
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    
    Dim monthsList As List
    monthsList.Initialize
    
    monthsList.Add("Jan")
    monthsList.Add("Feb") ...

...    monthsList.Add("Dec")
    monthsList.Add("All")
    
    acSpinPlantMonth.SetItems(monthsList)
    acSpinHarvestMonth.AddAll(monthsList)
End Sub


'======================================================================================================
Sub acSpinPlantMonth_SelectedIndexChanged (Index As Int)
    Dim itemStr As String
    
    itemStr = acSpinPlantMonth.GetItem(Index)
    Log("Item Plant Month - " & itemStr)

    setSpinGroupColor(acSpinPlantMonth, Colors.Red, 0xFFFFFFFF)
End Sub


'======================================================================================================
Sub setSpinGroupColor(comboBoxArg As B4XComboBox, textColorArg As Int, backGroundArg As Int)
    Dim spnr As Spinner = comboBoxArg.cmbBox

    spnr.TextColor                     = textColorArg
    spnr.DropdownBackgroundColor     = backGroundArg
    spnr.DropdownTextColor             = xui.Color_Black
End Sub

'======================================================================================================
Sub acSpinHarvestMonth_ItemClick (Index As Int, Value As Object)
    Dim itemStr As String
    
    itemStr = acSpinHarvestMonth.SelectedItem
    Log("Item Harv Month - " & itemStr)
    
    acSpinHarvestMonth.TextColor = Colors.Red   
    acSpinHarvestMonth.DropdownBackgroundColor = Colors.White
    acSpinHarvestMonth.DropdownTextColor        = xui.Color_Black
End Sub

Has anybody come across this before/

Are there any fixes?

Best regards
Rob
 

Attachments

  • SpinnerBug.zip
    4.1 KB · Views: 195
Top