Android Question How to get Checked_Change Sender

SternFaun

Member
Licensed User
Good evening together,

I got the following problem:

i create a ScrollView and add Checkboxes to it like this:

Private Check as Checkbox
Check.Initialize("Check")
Activity.AddView(Check,10%x,10%y,25%x,15%y)
Check.RemoveView
Check.Tag = i
'i is an ongoing number with +1 for each view, starts at i=0
ScrollView1.Panel.AddView(Check,50%x,TOP-12dip,100%x,10%y)

The problem is that I dont get the tag ("i") of my Checkbox by checking it in the app. I use this code:

Sub Check_CheckedChange
Check = Sender
Msgbox(Check.tag, "Test")
End Sub


It always returns the last i (highest tag-number) which was added to the ScrollView.Panel.

What can I do? I tried every thinkable variantions like:
Msgbox(ScrollView1.Panel.GetView(Check.Tag).Tag,"Test")
or others. The problem is that I dont get the Sender, but why. For Label-Views same seems to work.

Thanks for your help!
 

SternFaun

Member
Licensed User
Problem solved:
For each creation of a checkbox:
Dim Check as Checkbox
Check.Initialize("Check")
Check.Tag = i 'i is an ongoing number with +1 for each view, starts at i=0
ScrollView1.Panel.AddView(Check,50%x,TOP-12dip,100%x,10%y)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I don't understand this code:
B4X:
Private Check As Checkbox
Check.Initialize("Check")
Activity.AddView(Check,10%x,10%y,25%x,15%y)
Check.RemoveView
Check.Tag = i 'i is an ongoing number with +1 for each view, starts at i=0
ScrollView1.Panel.AddView(Check,50%x,TOP-12dip,100%x,10%y)
Why do you add the Checkboxes onto the Activity and remove them just after ?
This code is enough:
B4X:
Private Check As Checkbox
Check.Initialize("Check")
Check.Tag = i 'i is an ongoing number with +1 for each view, starts at i=0
ScrollView1.Panel.AddView(Check,50%x,TOP-12dip,100%x,10%y)
 
Upvote 0
Top