I think I had a similar issue I reported in the Bug Wish Forum. My issue wasn't only with one item (although that would be high on the list), but that the spinner will show the item in the label like you said, but never fires the event saying it is the selected item. So, even though there is an item selected the user still has to click the spinner and select it again for the event to fire. I had already made the workaround Erel suggested in the thread about firing the event myself or in my case where I populated the spinner I do an [If spinner.SelectedIndex > -1 then] just after populating and just set my variable storing the selection. It isn't as modular or class friendly, but works until the event is fixed to fire...if ever.
The workaround was in the post text- You either call the even yourself providing it the needed values like you mentioned in your first post, or you test SelectedIndex of the spinner after adding items to it and if > -1 it means an item is selected, so you can store it in whatever manner that you do in the event to use later so they don't need to click it and select it when it already is.
You could also use a hybrid of the two and test if > -1 then call the event with the values needed. (Safer if it is possible that the spinner could have 0 values and you hardcode the GetItem(0) which would be out of bounds of the list)
I have some code here in a View Manager class you may or may not have seen. I had lots of issues drawing spinners to begin with and along with this issue I have some code where I need the spinner to have a list sort of like a listview where it shows the user one thing and stores another value. I started changing the code to make a custom spinner using a label and a listview. I ran into issues drawing the listview since Activity isn't available in classes and then my wife had a baby. Haven't got to do much on it yet but plan to tweak it a little possibly this weekend. I'll update the code when finished.
Did you take a look at my View Manager Class above? It does this exact thing aside from tweaking the ExecuteSpinner method to work with it, and I just posted some example code yesterday showing the capabilities. The default behavior of the Spinner is to do what you describe and it has no text it can display other than what you provide, so a "Dummy" Record would be required to use it that way. You could tweak the ExecuteSpinner method to insert a prompt item in the spinner before the DB items to get a better effect too and don't have to put it in the DB if you wish to use the spinner.
'Executes the query and fills the Spinner with the values in the first column
Sub ExecuteSpinner(Prompt as String, SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Spinner1 As Spinner)
Spinner1.Clear
Spinner1.Add(Prompt)
Dim Table As List
Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
Dim Cols() As String
For i = 0 To Table.Size - 1
Cols = Table.Get(i)
Spinner1.Add(Cols(0))
Next
End Sub
A couple other possibilities would be setting the current selection to -1 after loading the DB values. You could also process the selection changed event and not allow setting it to the first value either by setting it to -1 there or re-prompting the user with the selection list.
That annoyance and the drawing issues with the font size being weird in the control and not many options is why I made my own. It isn't really hard to make your own using a 9 Patch image in a label then just handling the click of the label and showing an Input List.
In my class I have all the methods for the combobox by each other so you could just grab those, the SetNinePatchDrawable function, the GetCharSize function, and the 9 patch images for the combo and you'd have your own combobox. Modify/Create a new ExecuteSpinner to return a List that you could pass to the AddCombobox function and you'd be in business.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?