How read th "Button State"?

rubino25

Member
Licensed User
Longtime User
Hi..
I'm new in programming on Android and asked help with this!
I need to send data via Bluetooth only when I hold down a button. In vb6 it was not a problem, I think it was button.ispressed or similar .. but here just do not understand how to do .. Does anyone have any method?
 

joseluis

Active Member
Licensed User
Longtime User
What you want is to catch the Button events.

A button has the following events: Click, Down, Up & LongClick.

Every View (buttons included) has an event name (In the layout designer it can be defined under the EventName key, and if you add the view by code you define it in the initialization method:)
B4X:
buttonExample.Initialize("buttonExample")

The event name is the root name of the Sub that catches the events. That means that, in the previous example, in order to act on the Click event you create a Sub with this name:
B4X:
Sub buttonExample_Click
   ' Code that will be executed when clicking on the button
   ' with the event name set to "buttonExample"
End Sub

Then another sub for the long click, another for the pressing down, etc...
 
Upvote 0
Top