Problem filling a Spinner

GnFrNc

New Member
Licensed User
Longtime User
I have a problem filling a Spinner, I've tried to add the elements both with the Add(String) and Add(List) methods. Here's the source code:

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim spUser As Spinner
Dim btnConfirm As Button
Dim btnCancel As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim UsersList As List

Activity.LoadLayout("Login.bal")

UsersList.Initialize()
UsersList.Add("SQnet")
UsersList.Add("Admin")
UsersList.Add("MyUser")

spUser.Initialize("spUser")
spUser.Add(UsersList)
End Sub
Sub Activity_Resume
'
End Sub
Sub Activity_Pause (UserClosed As Boolean)
'
End Sub
Sub btnConfirm_Click
Activity.Finish
End Sub
Sub btnCancel_Click
Activity.Finish
End Sub

Thanks in Advance
Gianfranco
 

klaus

Expert
Licensed User
Longtime User
What exactly is your problem ?
If you look at the help file you will see that:
- Spinner1.Add(Item As String) adds a String
- Spinner1.AddAll(List As List) adds a List

I suppose that the Spinner is added in the layout file, if so, you must not initialize it with spUser.Initialize("spUser")

Try this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim UsersList As List
   
    Activity.LoadLayout("Login.bal")
   
    UsersList.Initialize()
    UsersList.Add("SQnet")
    UsersList.Add("Admin")
    UsersList.Add("MyUser")   
   
    spUser.AddAll(UsersList)
End Sub
To get the best advices it is better to also post your project as a zip file, or at least a smaller project that shows the problem (IDE menu File/Export As Zip).

Best regards.
 
Upvote 0

GnFrNc

New Member
Licensed User
Longtime User
Solved!

Hello Klaus,

You're right, it wasn't necessary to call the Initialize method and it also created the problem I had.

Thank you very much! :icon_clap:

Gianfranco
 
Upvote 0
Top