Android Question Missing element in ListView when loaded with cursor

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi all.

I have a strange one.

I am using the DB module to load a table into a listview.

Calling code

B4X:
Dim s As String = "select timer_desc from sstart order by used DESC,timer_desc ASC"
    db.ExecuteListView(g.oSQL,s,Null,0,lv,False)

DB Code is here

B4X:
Sub ExecuteListView(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, ListView1 As ListView, TwoLines As Boolean)'ignore

    ListView1.Clear
    Dim Table As List
    Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
    Dim Cols() As String
    For i = 0 To Table.Size - 1
        Cols = Table.Get(i)
        If TwoLines Then
            ListView1.AddTwoLines2(Cols(0), Cols(1), Cols)
        Else
            ListView1.AddSingleLine2(Cols(0), Cols)
            Log(Cols(0))
        End If
    Next
End Sub

The problem is that the last record in the table is not shown. In other words I have 7 records but only 6 show up. I verfied this by adding the LOG statement and I see the 7th record. it just never shows up in the listview.

Very strange...
 

DonManfred

Expert
Licensed User
Longtime User
You should have a single line at the end due to
ListView1.AddSingleLine2(Cols(0), Cols)

Maybe Cols(0) should be Cols(1)?

What does log("0: '"&cols(0)&"'") put in the log?
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
What does log("0: '"&cols(0)&"'") put in the log?

That's just it, all 7 records end up in the logs. But only 6 records in the listview so I know the loop is working.
Like I said, very strange.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Its so strange, Works in the genymotion emulators.
Does not work in a China 7 inch tablet. Oh. well.
Lets close this.
 
Upvote 0
Top