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 ...


B4X:
       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
 

DonManfred

Expert
Licensed User
Longtime User
There is no lock in Listview.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
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.
B4X:
c=s.ExecQuery("SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS LIMIT 0,15")
 
Upvote 0

MarcioCC

Member
Licensed User
Longtime User
Good morning, I really just want to add 15 records.
Do you have an example of how I use LIMIT?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
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

B4X:
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
Top