ProgressBar not redraw

Fabrice La

Active Member
Licensed User
Longtime User
Hi

I have :
B4X:
Sub Globals
   Dim Maximo As Int
   Dim ProgressBar1 As ProgressBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Main")
   ProgressBar1.Initialize("ProgressBar1")
End Sub

Sub Button1_Click
   Dim fileliste As List
   fileliste = File.ListFiles(File.DirRootExternal & "/tmp")
   Maximo = fileliste.Size - 1
   For i = 0 To fileliste.Size - 1
                If  i Mod Maximo = 0 Then
         ProgressBar1.Progress = i/Maximo*100
         DoEvents 
      End If
   Next 
   activity.Finish
End Sub
The ProgressBar doesnot show progress ... ???
 

klaus

Expert
Licensed User
Longtime User
B4X:
Maximo = fileliste.Size - 1
  For i = 0 To fileliste.Size - 1
    If  i Mod Maximo = 0 Then
It's normal, i Mod Maximo will never be 0 in the loop!
Add a Log(( i Mod Maximo)) in you code, just before the If statement, to show its value.
You should use:
B4X:
For i = 0 To Maximo
    ProgressBar1.Progress = i/Maximo*100
    DoEvents 
Next
Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…