I have been looking for an example of a spinner function. My application
requires that the spinner support two arguments; i.e. (1) an identity, and
(2) a key that will be returned when the identity is selected. It appears
that little documentation is available on spinners.
First you have to fill the Spinner (after dimming and initializing of course):
B4X:
Dim Spinner1 as Spinner
Spinner1.initialize("Spinner1)
Dim Antwort as EditText ' or String - i display datas in a EditText in this case
Spinner1.AddAll (Array As String("Choose...","Item1","Item2","Item3"))
Then you can catch the selction of the spinner like this:
B4X:
If Spinner1.SelectedIndex = "1" Then
Antwort.Text = "1. item"
End If
If Spinner1.SelectedIndex = "2" Then
Antwort.Text = "2. item"
End If
That'S the way i am working with spinners :sign0060:
When populating the spinner, you can create a list containing the returned keys. You may then get the desired key by using the position of the spinner.