Load Spinner depending on selection of another

DCooper

Member
Licensed User
Longtime User
How do I use spinner1 with variables, say A,B,C.
Spinner2 loads with 1,2
Spinner1 is preselected with A.
User Selects B from Spinner1, so I want to add 3 & 4 to Spinner2
User Selects C from Spinner1, so I want to add 3,4,5,6 to Spinner2

How would I do this?

Thanks,
DCooper
 

klaus

Expert
Licensed User
Longtime User
B4X:
Sub Globals
    Dim spn1, spn2 As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
    spn1.Initialize("spn1")
    Activity.AddView(spn1, 20dip, 20dip, 200dip, 50dip)
    
    spn2.Initialize("spn2")
    Activity.AddView(spn2, 20dip, 90dip, 200dip, 50dip)
    
    spn1.Add("A")
    spn1.Add("B")
    spn1.Add("C")
    
    spn1_ItemClick(0, "A")    ' sets Spinner spn2
End Sub

Sub spn1_ItemClick (Position As Int, Value As Object)
    spn2.Clear
    Select Value
    Case "A"
        spn2.Add("1")
        spn2.Add("2")
    Case "B"
        spn2.Add("1")
        spn2.Add("2")
        spn2.Add("3")
        spn2.Add("4")
    Case "C"
        spn2.Add("1")
        spn2.Add("2")
        spn2.Add("3")
        spn2.Add("4")
        spn2.Add("5")
        spn2.Add("6")
    End Select
End Sub
I think that when the user lcicks on B after C you want to remove 5 and 6 from Spinner2.
So Spinner2 is cleared each time Spinner1 is clickes and filled with the desired values.

Best regards.
 
Upvote 0

manuaaa

Member
Licensed User
Longtime User
Thanks Klaus sir,
can we make it from local Database ? I am doing it from web data and work perfectly.
This is my code to fill data from web data base

a.setDatabase("XXX.XX.XXX.xx","manwin","XXXXXXXX","XXXXXXXX")
L = a.Query("SELECT REPORTINGTO FROM fs where name = '" &Spinner1.selecteditem & "' ")
For i = 1 To L.Size -1
strColumn=L.Get(i)
strColumn= strColumn.Replace("[","").Replace("]","")
Spinner2.Add(strColumn)
MgtTxt.Text = strColumn
Next


kindly help me to get data from local database

thanks in advance
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Don´t post questions to a 2 Year old thread!
Take the info Klaus gave to you in the other thread and read the beginners guides sqlite-part

Search for Tutorils here in forum and do your first steps. If you THEN encounter any issues feel free to create a NEW THREAD for this question. Post the code you have written and which is not working and describe the problem and what you expect and what errors you get....

We do NOT write the code for you. We just want to HELP.
 
Upvote 0
Top