Android Question Listview problem

Duncan H Williamson

Member
Licensed User
Longtime User
B4X:
Sub gethistory(hivehst As String)
    listview1.Initialize("ListView1")
    listview1.ScrollingBackgroundColor = Colors.Gray
    listview1.SingleLineLayout.Label.TextSize = 16
    listview1.SingleLineLayout.Label.TextColor = Colors.Black
    listview1.SingleLineLayout.Label.Gravity = Gravity.CENTER
    listview1.SingleLineLayout.Label.Typeface =Typeface.DEFAULT_BOLD
    listview1.FastScrollEnabled = False
   
   
    Dim i As Int
    Dim Cursor1 As Cursor
    Label1.Text = Label1.Text & " History"
    Cursor1 = sql1.ExecQuery("SELECT * FROM hivevisit where hivename  = '" & hivehst  & "' order by vdate")
    If Cursor1.RowCount > 0 Then
        Label1.Text = Label1.text & Cursor1.RowCount
    Dim rowdetail(Cursor1.RowCount) As String
    Dim quarantine(Cursor1.RowCount) As String
    For i = 0 To (Cursor1.RowCount - 1    )
       
    Cursor1.Position = i   
        listview1.AddSingleLine(Cursor1.GetString("visit_date") & i)
               
    Next
           
    Else
        rowdetail(i) = "No previous History"
    End If
    Cursor1.Close   
    Panel4.Visible = True
    Panel4.AddView(listview1,0, 0,100%x, 100%y)
   
end sub

Hi All, I am having an issue with a listview not showing all the rows from a data table...
I have a panel in my app which contains the listview, all it needs to do is display a field with a date from a sqlite table the table has 14 rows, however only 8 rows show in the listview. I added the rowcount to a label and it shows it has selected 14 rows, but the listview only shows the first eight rows. the panel is half the height of the activity
I have attached the code from the sub that loads this listview... I am tearing out what little hair I have out
Any help from the resident experts would be greatly appreciated !!

Regards

Duncan
 

Duncan H Williamson

Member
Licensed User
Longtime User
HiI think I have sorted it !! I changed
Panel4.AddView(listview1,0, 0,100%x, 100%y)
to
Panel4.AddView(listview1,0, 0,Panel4.Width, Panel4.Height)
now I have all the rows and it scrolls cleanly !!
 
Upvote 0

Duncan H Williamson

Member
Licensed User
Longtime User
How many times do you call Sub gethistory.
If you call it more than one time, be aware that you add a new ListView each time!
Hi Klaus It only gets called once normally, however the sub normally does not contain all the code shown, i cut and pasted it into the sub just to show everything I was doing
 
Upvote 0
Top