spinner does not trigger values from scroll panel

sanjibnanda

Active Member
Licensed User
Longtime User
My spinner works and raise events when declared in main activity, but it fails when it is accessed from scroll view. My code is as given.
B4X:
'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 btn1, btn2 As Button
Dim ScrollView1 As ScrollView
Dim label1,label2 As Label
Dim spin1 As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
   Activity.LoadLayout("main")
   ScrollView1.Panel.Height = 800dip 
   
   btn1.Initialize("")
   btn1.Text = "True"
   
   btn2.Initialize("")
   btn2.Text = "False"
   
   label1.Initialize("")
   label1.Text = "True"
   label1.Color = Colors.Cyan
   
   label2.Initialize("")
   label2.Text = ""
   label2.Color = Colors.Yellow
   
   spin1.Initialize("") 
   ScrollView1.Panel.AddView(spin1, 10dip, 5dip, 200dip, 50dip)
   ScrollView1.Panel.AddView(btn1, 10dip, 55dip, 200dip, 50dip)
   ScrollView1.Panel.AddView(btn2, 10dip, 105dip, 200dip, 50dip)
   ScrollView1.Panel.AddView(label1, 10dip,155dip, 200dip, 50dip)
   ScrollView1.Panel.AddView(label2, 10dip,205dip, 200dip, 50dip)
   spin1.AddAll(Array As String("a", "b", "c", "d"))
'   btn1.Visible = False
'     btn2.Visible = False
   


End Sub
Sub Spin1_ItemClick (Position As Int, Value As Object)
   '<<<<<<see here nothing is triggered >>>>>>>

   If Value = "a" Then 'this is the item text
    btn1.Visible = True  
     btn2.Visible = False
     label1.Text = "True"
   label2.Text = Value
     Else
      btn1.Visible = False
     btn2.Visible = True
   label1.Text = "False"
   label2.Text = Value
End If
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

plz correct me where i am wrong. I will appreciated if i could get working modified code rather than ideas..as i am newbie here.

regards,
 
Top