Android Question Sender is null

Rusty

Well-Known Member
Licensed User
Longtime User
I have created a scrollview in the designer and then in code I add check box views:
B4X:
Dim chkbx As CheckBox
chkbx.initialize("chkbx")
chkbx.text = "checkbox"
ScrollView1.panel.addview(chkbx, 0dip, 0dip, 100dip, 100dip)


...

sub chkbx_Click
   Dim x as checkbox
   x = sender
''''at this point sender is null

The click event fires but SENDER is null.
Any ideas of what causes this?
Rusty
 

inakigarm

Well-Known Member
Licensed User
Longtime User
The Checkbox event is not Click, is CheckedChange:

B4X:
Sub CheckBox1_CheckedChange(Checked As Boolean)
 
End Sub
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
my mistake, in my post, i typed it instead of copying it from code.
My code has chkbx_checkedChange(checked as boolean)
and Sender is NULL when the checkedchange event fires...don't understand why...


I took out all breakpoints and the Sender NULL issue disappeared...argh!
Thanks for the help :)
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
Works here (adding the checkbox at Designer - layout):

B4X:
Sub CheckBox1_CheckedChange(Checked As Boolean)
    Dim x As CheckBox
    x=Sender
    Log(x.Tag)
End Sub

Have you added the checkbox by code?
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks all,
in my post #3, i edited it and indicated that the NULL issue was due to having a debug breakpoint.
Once removed, the NULL issue of Sender went away.
I appreciate the responses :)

And yes, I create many checkboxes in code and I do dimension each one...I got caught on that one several years ago :) (thanks)
Rusty
 
Upvote 0
Top