Android Question Spinner add to list

anaylor01

Well-Known Member
Licensed User
Longtime User
In the code below it is just adding the text like "Team 2", "Team 3", "Team 4". So what am I doing wrong?
Dim tcnt As Int
Dim IC As Int
Dim tmcnt As String
Dim tmname As String
tcnt = spnNumteams.SelectedItem
For IC = 2 To tcnt
tmcnt = """Team " & IC & ""","
tmname = tmname & tmcnt
Next
tmname = tmname.SubString2(0,tmname.Length -1)
spnNameTeams.Clear
spnNameTeams.AddAll (Array As String(tmname))
 

Johan Schoeman

Expert
Licensed User
Longtime User
In the code below it is just adding the text like "Team 2", "Team 3", "Team 4". So what am I doing wrong?
Dim tcnt As Int
Dim IC As Int
Dim tmcnt As String
Dim tmname As String
tcnt = spnNumteams.SelectedItem
For IC = 2 To tcnt
tmcnt = """Team " & IC & ""","
tmname = tmname & tmcnt
Next
tmname = tmname.SubString2(0,tmname.Length -1)
spnNameTeams.Clear
spnNameTeams.AddAll (Array As String(tmname))
Your FOR loop starts at 2. Thus, it adds from Team 2 onwards. What is the outcome that you are expecting?
 
Last edited:
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I want it to start at team 2. The problem is populating the spinner with the separate values. Team 1, Team 2, Team 3 etc... ON different lines.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I want it to start at team 2. The problem is populating the spinner with the separate values. Team 1, Team 2, Team 3 etc... ON different lines.
Do it like this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
 
    For i = 2 To 10
        Spinner1.Add("""Team " & i & """")
    Next

End Sub

1.png
 
Upvote 0
Top