ProgressBar after itemclick

Discussion in 'Android Questions' started by tcgoh, Mar 26, 2012.

  1. tcgoh

    tcgoh Active Member Licensed 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.

    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I guess that the query itself takes most of the time. This means that you will not be able to do anything during this time as it is not your code running.

    I recommend you to use the full text search feature of SQLite. It will make this query extremely fast: SQLite FTS3 and FTS4 Extensions
     
  3. tcgoh

    tcgoh Active Member Licensed User

    Tks Erel, how about wait cursor?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can show a progress dialog. However it will not be animated.
     
  5. timo

    timo Active Member Licensed User

    Code:
    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: Mar 26, 2012
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice