Android Question count clicks

jafarbahrami

New Member
How to count the number of clicks on the touch screen and print on a label
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: false
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim Label1 As Label
Dim panel1 As Panel
Dim c As Int=0
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("cont")

Label1.Text=c

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub panel1_thach
c=c+1
End Sub
 
Last edited:

eurojam

Well-Known Member
Licensed User
Longtime User
I suppose you are meaning something like this:
B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    If Action=Activity.ACTION_DOWN Then
      c=c+1
    End If
    label1.Text = c
End Sub

pleae use code tags, then your code is readable...
 
Upvote 0
Top