Android Question Canvas

kohle

Active Member
Licensed User
Longtime User
I use the canvas object for drawing some lines and rectangles on the screen.

I need a pause of 2 seconds between every line or retangle drawn.

I tried sleep function but dont work.
 

kohle

Active Member
Licensed User
Longtime User
I have about 100 lines drawn in a loop ,
I am not sure how to draw this with a timer, because I need the loop
also for other things which have be done.

Now I see all lines , when the last line is drawn, but I want to see each line drawn on the screen.

I am looking for a refresh or repaint
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
The UI will not refresh until your sub ends. Klaus' suggestion is correct, create a timer and handle the drawing in the tick event. For example:
B4X:
Sub Process_Globals
 Private DrawTimer As Timer
End Sub
Sub Globals
 Private LoopCount As Int
End Sub

Sub Activity_Resume
 DrawTimer.Initialize("DrawTimer", 2000)
 LoopCount = 0
 DrawTimer.Enabled = True
End Sub
Sub Activity_Pause
   DrawTimer.Enabled = False
End Sub
Private Sub DrawTimer_Tick
 If LoopCount > 100 Then
  DrawTimer.Enabled = False `
 Else
  ' draw our stuff
  LoopCount = LoopCount + 1
 End If
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…