Android Question ListView problems

KentB

Member
Licensed User
Longtime User
A listview is not always displaying all lines using the code below. What's the root cause ? Thanks for ideas and answers.

Code extract:
Sub Globals
...
Private ListView1 As ListView
...
Sub Activity_Create(FirstTime As Boolean)
ScrollView1.Initialize(1000dip) ' a scrollview is placed beside the listview
...
ListView1.Initialize("ListView1")
Activity.AddView(ListView1, ScrollView1.Width + 10dip, 5dip, Activity.Width - ScrollView1.Width - 12dip, Activity.Height-
10dip)
...

Sub Calc_Click

Dim generalData() As String
Dim headline As String
Dim data() As String

...
ListView1.Clear

ListView1.SingleLineLayout.ItemHeight = 100dip
ListView1.SingleLineLayout.Label.TextSize = 20
ListView1.SingleLineLayout.Label.TextColor = Colors.Black
ListView1.SingleLineLayout.Label.Gravity = Gravity.LEFT

generalData = myLib.GetGeneralData()

For i = 1 To generalData.Length
ListView1.AddSingleLine(generalData(i-1)) 'these about 10 lines are usually displayed
Next

ListView1.TwoLinesLayout.ItemHeight = 100dip
ListView1.TwoLinesLayout.Label.TextSize = 20
ListView1.TwoLinesLayout.Label.TextColor = Colors.Black
ListView1.TwoLinesLayout.Label.Gravity = Gravity.LEFT

'sometimes none or only 15-20 first of these "records" are displayed
'data is checked and correct (strings and string arrays correct)
'it seems that once the ListView contains a number of rows it will not expand to more rows but Clear 'is used in code above
For j = 1 To 100
headline = myLib.getHeadline(j-1)
ListView1.AddTwoLinesAndBitmap("Item#" & j, headline, BitmapHeadLine)

data = myLib.getData(j-1)
For k = 1 To data.Length
ListView1.AddSingleLine(data(k-1))
Next
Next
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Please use code tags when posting code!

Most probably it is better to create a small project which shows the problem. Export the project as ZIP (in the IDE File->Export as zip) and upload it here.
 
Upvote 0

KentB

Member
Licensed User
Longtime User
Thanks. (Un-) fortunately I don't see the problem in the small project. I have to investigate further...
Generally I would like the scrollview and listview to keep/display the same values and position (scroll) after turning the device.

Attached the zip file anyway.
 

Attachments

  • test.zip
    10.1 KB · Views: 158
Upvote 0

KentB

Member
Licensed User
Longtime User
Thanks for your answers so far. I will come back when I have an answer to the problems in the first case.
 
Upvote 0
Top