Android Question What can i get more object.Initialize("object"&number) data?

李春雄

Member
Licensed User
Longtime User
What can i get more object.Initialize("object"&number) data?

B4X:
Sub Activity_Create(FirstTime As Boolean)   
    Activity.LoadLayout("Layout_Examination_UI")   
    Dim examsTitle As Int = 0
    For titleQuantity = 0 To 4
        autoSpinner.Initialize("autoSpinnerEvent")
        autoPanels.AddView(autoSpinner,540dip,((titleQuantity+1)*100)+10dip,150dip,50dip)
        'example
        autoSpinner.Tag="autoSpinnerEvent"&(titleQuantity+1)
        autoSpinner.Add("item 1")
        autoSpinner.Add("item 2")
        autoSpinner.Add("item 3")
        autoSpinner.Add("item 4")
        autoSpinner.TextSize = 20
    Next   
End Sub

error in this
B4X:
Sub btnQRCode_Click
    Dim tmpstr As String
    For i = 0 To 4
        If "autoSpinnerEvent"&(i+1) = autoSpinner.Tag Then
            tmpstr = autoSpinner.SelectedItem & ":" & tmpstr
        End If
    Next
    Msgbox(tmpstr,"")
End Sub

think you everyone!!
 

李春雄

Member
Licensed User
Longtime User
the file is my example, i need get Spinner0,Spinner1,Spinner2,Spinner3,Spinner4 SelectedItem,
thank you Erel.

B4X:
Sub Globals
    Dim autoSpinner As Spinner
    Dim titleQuantity As Int = 0
   
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
   
    For titleQuantity = 0 To 4
        autoSpinner.Initialize("Spinner"&titleQuantity)
        autoSpinner.Add("test1")
        autoSpinner.Add("test2")
        autoSpinner.Add("test3")
        Activity.AddView(autoSpinner,10dip,(titleQuantity*80)+10dip,100dip,60dip)
    Next

End Sub

Sub Button1_Click
    For titleQuantity = 0 To 4
        '   "Spinner"&titleQuantity : Spinner0,Spinner1,Spinner2,Spinner3,Spinner4
        Dim autoSpinnerValue As Spinner
        autoSpinnerValue = Sender
        Msgbox(autoSpinnerValue.SelectedItem,"")
    Next
End Sub
 
Upvote 0
Top