B4J Question [SOLVED]Using Map to set ComboBox selected index

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I am trying to set the selected index of a ComboBox from a value stored in a map but keep getting a 'null' string error.

The map has 40 items in it, each row is payMap.Put("ID",indexNo) etc

The map values when the error occurs are - key="PR" value =30
debug reports 'id' as "PR" yet debug "Pay Index = null"

The sub is:
B4X:
'Set the Payment Type ComboBox
Sub setPayType(id As String)
    LogDebug("id = "&id)
    If id = "0" Then
        cbPayment.SelectedIndex = 0  
    Else
        LogDebug("Pay Index = "&payMap.Get(id))
        cbPayment.SelectedIndex = payMap.Get(id)  
    End If
'  
End Sub

I was under the impression that payMap.Get(id) would return 30 as the value.

Can someone tell me where I am wrong?

Thanks

[Solved] I found a trailing space in the Key. Trim before adding to Map
 
Last edited:
Top