Spinner does NOT get populated

Cableguy

Expert
Licensed User
Longtime User
I have this code:
B4X:
   Spinner1.Initialize("Categories")
   SQL1.Initialize(File.DirInternal,"Equations.s3db",False)
   Cursor1 = SQL1.ExecQuery("SELECT Name FROM Categories")
   Dim Item As String
   Spinner1.Add("Paulo")
   For i = 0 To cursor1.RowCount - 1
      Cursor1.Position = i
      Item = Cursor1.GetString("Name")
      Msgbox(Item,"")
      Spinner1.Add(Item)
   Next

The messagebox shows that the resuts ARE in fact beeing retrieved from the sql database, but the spinner does NOT get populated...Nor even when adding a value using Spinner1.Add("Paulo") it does NOT get Added...why??

EDIT: I added as a Title to the msgbox the Spinner1.Size and it seems that the Items are in fact being added to the spinner, but when I tap the Spinner I get only an empty row at the midle of my screen.!
Am I missing something?
 
Last edited:

andrewtheartuncc

New Member
Licensed User
Longtime User
same problem here

I am having the same exact problem.

It is a spinner called "StateDropdown" that I initially created in the Designer.

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

        ' Create an array of states
 
   Dim StateDropdown As Spinner

  

   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
      
    Dim statesarray() As String
    Dim statesstr As String
    statesstr = "Alabama,Alaska,American Samoa,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Guam,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Northern Marianas Islands,Ohio,Oklahoma,Oregon,Pennsylvania,Puerto Rico,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Virgin Islands,Washington,West Virginia,Wisconsin,Wyoming"
    statesarray = Regex.Split(",",statesstr)
   
    StateDropdown.Initialize("StateDropdown")
    StateDropdown.AddAll(statesarray)
    StateDropdown.Add("Test")
    Dim layoutname As String
    layoutname = "mainview.bal"
    Activity.LoadLayout(layoutname)   
   

End Sub
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Cableguy:

If you created the spinner in Designer you should not initialize it in your code.

andrewtheartuncc:

Rearrange your sub:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim layoutname As String
    layoutname = "mainview.bal"
    Activity.LoadLayout(layoutname)      
      
    Dim statesarray() As String
    Dim statesstr As String
    statesstr = "Alabama,Alaska,American Samoa,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Guam,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Northern Marianas Islands,Ohio,Oklahoma,Oregon,Pennsylvania,Puerto Rico,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Virgin Islands,Washington,West Virginia,Wisconsin,Wyoming"
    statesarray = Regex.Split(",",statesstr)
   
    StateDropdown.Initialize("StateDropdown")
    StateDropdown.AddAll(statesarray)
    StateDropdown.Add("Test")

End Sub
so that the layout is loaded before poulating the spinner.
 
Upvote 0

andrewtheartuncc

New Member
Licensed User
Longtime User
thanks

Thanks - that worked! I appreciate it so much )

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…