Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim bm As Bitmap
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 iv As ImageView
Dim pn As Panel
Dim cnv As Canvas
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("Layout1")
iv.Initialize("")
bm.InitializeMutable(300dip,300dip) 'create a 300x300 bitmap
iv.Bitmap = bm 'assign the bitmap to the imageview
Activity.AddView(iv,10dip,10dip,300dip,300dip) 'add the imageview to the activity
pn.Initialize("pn")
pn.Color = Colors.Transparent
Activity.AddView(pn,10dip,10dip,300dip,300dip) 'add a transparent panel for touch events
cnv.Initialize2(bm)' create a canvas for drawing
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub pn_Touch (Action As Int, X As Float, Y As Float)
If Action = Activity.ACTION_DOWN Then
cnv.DrawCircle(X,Y,10dip,Colors.Green,True,1) 'draw a circle where we touched
iv.Invalidate3(X-10dip,Y-10dip,X+10dip,Y+10dip) 'redraw the area where we just added a circle
End If
End Sub