Android Question How to use 'Wait for' when loading data in a spinner

demonio_jack

Member
Licensed User
Hi everyone!!!
I'm loading data from a database and I don't know how to show a progressbar during the process. Just want to show a progress circle to show users that data is loading...

this is teh code:
'********************************************
B4X:
Sub CargarDatosJ
    Try
        pgbBarra.Visible=True
       
        Starter.Connect
        Dim cur As JdbcResultSet= Starter.mysql.ExecQuery("select concat(idcategoria,' - ',nombre) categoria from categorias1 where activa=1 order by nombre")
        Do While cur.NextRow
            spnCategorias.add(cur.GetString("categoria"))
        Loop
        spnCategorias.SelectedIndex=6
        cur.Close
        Dim niv As JdbcResultSet = Starter.mysql.ExecQuery("select concat(idnivel,' - ',descripcion) nivel from niveles")
        Do While niv.NextRow
            spnNiveles.add(niv.GetString("nivel"))
        Loop
        spnNiveles.SelectedIndex=1
        niv.Close
    Catch
        Log(LastException)
    End Try
    Starter.CloseConnection
    pgbBarra.Visible=False
End Sub
'********************************************
Any idea???

Thanks. ;-)
 

Peter Simpson

Expert
Licensed User
Longtime User
Hey @demonio_jack
  1. First you need to know how many records you are going to return
  2. In your Do While make sure to have a counter i + i + 1 etc
  3. Use following code to map the record counter range to the progress bar value, you will need Sleep(0)

How many records are you returning???
 
Upvote 0

demonio_jack

Member
Licensed User
Hey @demonio_jack
  1. First you need to know how many records you are going to return
  2. In your Do While make sure to have a counter i + i + 1 etc
  3. Use following code to map the record counter range to the progress bar value, you will need Sleep(0)

How many records are you returning???
not over 100 rows..
 
Upvote 0
Top