Sender Problem

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
I create dinamically 20 buttons, and when I click on one, I need to know its caption, so I use sender.

But using this code:
B4X:
Sub bt_mac_click

Dim bt As Button
bt = Sender
lb_mac.Text = bt.Text

Log(sender) = android.widget.Button@4133cda8

the result is always the same, that is the caption of the last button created.
I'm sure about 2 weeks ago, the code worked, and now not.

How can I solve? :BangHead:
 
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Can you post the code where you create the buttons?
Most probably you didnt Dim them inside the loop.

You're right thedesolatesoul!!
I inserted the "dim" inside the loop, and now it works!
Many thanks!!! :icon_clap::icon_clap::sign0142:
 
Upvote 0
Top