Android Question Locking records in a Listview

MarcioCC

Member
Licensed User
Longtime User
Good night friends, I want to do the following, I have a (for) loop that adds records in a listview, I want to lock this loop in 15 records as I do this.
Follow the code in my loop ...


Code: Copy
       c=s.ExecQuery("SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS")
     
                  Lvadiciona.Clear
     
                   If c.RowCount >0 Then
                   For i=0 To c.RowCount-1
                   c.Position=i
                   
                                             
           
              Lvadiciona.AddTwoLinesAndBitmap(C.GetString ("CODBARRAS"), C.GetString ("QUANTIDADE"),LoadBitmap(File.DirAssets,"icone_lixeira6.jpg"))
                                 
                                       
            Next
             
           
            End If
            End If
 
There is no lock in Listview.
 
Upvote 0
I want to lock this loop in 15 records as I do this.
You want to ONLY add 15 Records, not more?
If yes then you should use LIMIT in your Query.
Code: Copy
c=s.ExecQuery("SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS LIMIT 0,15")
 
Upvote 0
If the records obtained are less than 15 then loads all read records.
If they are more than 15 stops at record 14, which would be the 15th

Code: Copy
c=s.ExecQuery("SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS")
Lvadiciona.Clear

If c.RowCount >0 Then
    For i=0 To Min(c.RowCount-1,14)
        c.Position=i
        Lvadiciona.AddTwoLinesAndBitmap(C.GetString ("CODBARRAS"), C.GetString ("QUANTIDADE"),LoadBitmap(File.DirAssets,"icone_lixeira6.jpg"))
    Next
End If
 
Upvote 0
Back
Top