ProgressBar after itemclick

tcgoh

Active Member
Licensed User
Longtime User
Hi,

I have a spinner with a drop down list and a itemclick which activate a SQLtableread.

How do I code a progressbar to start when a spinner_itemclick is selected until the scrollview is shown?

Tks.

B4X:
Sub spinpage2_itemclick (position As Int, value As Object)
   
   pb.BringToFront
   pb.Visible = True
   pb.Progress = 1
   lblValue1_P2.Text = spinpage2.SelectedItem
   SQLTableRead
   
End Sub

Sub SQLTableRead ' Reads the SQL data base
   Dim i As Int
   Dim Cursor1 As Cursor
   Dim txt, wtxt As String

   txt = "SELECT name FROM table WHERE name LIKE '%"&lblValue1_P2.Text&"%'"
   
   
   Cursor1 = SQL1.ExecQuery(txt)
   
   Dim Col(NumberOfColumns) As String
   
   SetHeader(ColumnName)
   NumberOfRows = 0

   For i = 0 To Cursor1.RowCount - 1
      Dim Col(NumberOfColumns) As String
      Cursor1.Position = i
      For j = 0 To NumberOfColumns - 1
         Col(j) = Cursor1.GetString(ColumnName(j))
      Next
      AddRow(Col)
      
   Next
   Cursor1.Close
   Activity.Title = DBFileName
   
   pb.Progress = 100
   
End Sub
 

timo

Active Member
Licensed User
Longtime User
B4X:
For i = 0 To RowCount-1
      'put your code here plus:
      pb= 100*i/(RowCount -1)
      'Log (pb)
        Label1.Text=pb&"%"
        doevents
Next
   Label1.Text=""

pb progresses from 0 to 100% and you can animate your own progressbar (or simply show the progress% in a label).
(This however slows the loop: it is better put LIMIT in the query).
 
Last edited:
Upvote 0
Top