P pchowning Member Licensed User Longtime User May 9, 2013 #1 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.
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.
GMan Well-Known Member Licensed User Longtime User May 9, 2013 #2 First you have to fill the Spinner (after dimming and initializing of course): Code: Copy 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: Code: Copy 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: Last edited: May 9, 2013 Upvote 0
First you have to fill the Spinner (after dimming and initializing of course): Code: Copy 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: Code: Copy 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:
M Mahares Expert Licensed User Longtime User May 9, 2013 #3 Actually, Gman, it is easier if you do this to avoid all the if statements , especially if you have a large spinner, it can be tedious. Code: Copy Sub spinner1_ItemClick (Position As Int, Value As Object) Antwort.Text =Value End Sub Upvote 0
Actually, Gman, it is easier if you do this to avoid all the if statements , especially if you have a large spinner, it can be tedious. Code: Copy Sub spinner1_ItemClick (Position As Int, Value As Object) Antwort.Text =Value End Sub
mc73 Well-Known Member Licensed User Longtime User May 10, 2013 #4 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. Upvote 0
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.