R rubino25 Member Licensed User Longtime User Feb 1, 2012 #1 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?
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 Feb 1, 2012 #2 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 Code: Copy 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: Code: Copy 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
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 Code: Copy 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: Code: Copy 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...
R rubino25 Member Licensed User Longtime User Feb 1, 2012 #3 Thank you! =) The problem arises because I have to send data only when I hold down the button. With the click event send the data, but if I hold down the button, nothing happens! I found this in the forum: http://www.b4x.com/forum/basic4andr...3332-can-b4a-do-repeat-buttons.html#post75127 Using the timer works, but I would like to know if there's another way .. Upvote 0
Thank you! =) The problem arises because I have to send data only when I hold down the button. With the click event send the data, but if I hold down the button, nothing happens! I found this in the forum: http://www.b4x.com/forum/basic4andr...3332-can-b4a-do-repeat-buttons.html#post75127 Using the timer works, but I would like to know if there's another way ..
joseluis Active Member Licensed User Longtime User Feb 1, 2012 #4 That is a good solution. It doesn't occur to me a better way to do it. Upvote 0