French Spinner item

Tata Mapassa

Member
Licensed User
Longtime User
Bonjour,

J'ai un spinner avec des données d'une table comme cela Cur.GetString("Champ1") & ". " & Cur.GetString("Champ2") & ", " & Cur.GetString("Champ3") & ", " & Cur.GetString("Champ4") sur une ligne et je souhaiterai que l'action Spinner1_ItemClick affiche uniquement le champ4.
Merci
 

Tata Mapassa

Member
Licensed User
Longtime User
Les données sont récupérées d'une table et affichée dans le spinner. Elles sont séparées par ", " à partir du champ2 à 4.
 

Tata Mapassa

Member
Licensed User
Longtime User
Ci-dessous comment je récupère les données de la table. Merci

Sub Liste
Dim Cur As Cursor
Spinner1.Clear
Cur = SQL1.ExecQuery("SELECT * FROM Table")
For I = 0 To Cur.RowCount - 1
Cur.Position = I
Dim Listemal As List
Dim cont1 As String
cont1 = Cur.GetString("champ1) & ". " & Cur.GetString("champ2") & ", " & Cur.GetString("champ3") & ", " & Cur.GetString("champ4")
Listemal = Array As String(cont1)
Spinner1.Addall(Listemal)

Next
Cur.Close

End Sub
 

mcqueccu

Well-Known Member
Licensed User
Longtime User
Based on @klaus response


B4X:
Private Sub Spinner1_ItemClick (Position As Int, Value As Object)
    Dim dataSplit() As String = Regex.Split(",",Value)
    'hard coded position
    Log(dataSplit(3))
    
    'or get last itme
    Log(dataSplit(dataSplit.Length-1))
    
End Sub
 

Tata Mapassa

Member
Licensed User
Longtime User
the application crashes using the code below. Thank you for your help
Private Sub Spinner1_ItemClick (Position As Int, Value As Object)
Dim dataSplit() As String = Regex.Split(",",Value)
'hard coded position
Log(dataSplit(3))

'or get last item
Log(dataSplit(dataSplit.Length-1))
label1.text = dataSplit(3) or dataSplit(dataSplit.Length-1)
End Sub
 

Tata Mapassa

Member
Licensed User
Longtime User
Error resolved by rampplacing the "." by "," in the code below:
cont1 = Cur.GetString("field1) & ". " & Cur.GetString("field2") & ", " & Cur.GetString("field3") & ", " & Cur.GetString("field4")
Thank you for your help and availability
 
Top