Button click

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I am adding a button to a page using the following code:

B4X:
close_button.initialize(500)
Activity.AddView(close_button,0,(100%y - 45dip),(100%x),45dip)
close_button.Text = "Click to close"

I then are trying to make it so when you click it, display a message box.
I am using the following code but it don't seem to be working.

B4X:
Sub close_button_Click
Msgbox("test message","title")
End Sub

under 'Sub Globals' I have put:

B4X:
Dim close_button As Button

when I tap on the button on my page it don't seem to do anything..

Anyone know where I went wrong?
 

Inman

Well-Known Member
Licensed User
Longtime User
Why are you initialising the button as close_button.initialize(500)? Within the brackets it should be the name you are planning to use to detect the events for the button. For example it could be close_button.initialize("close_button") and then use the same name to detect the clickevent Sub close_button_Click.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

Oh, I was wondering what the (500) meant.

I was using the code from another project.

Thanks for clearing it up for me.
 
Upvote 0
Top