Problem with parameter Height of ListView

GMan

Well-Known Member
Licensed User
Longtime User
I am using the following code to display a huge list of items:

B4X:
Dim NEMListView As ListView 
    NEMListView.Initialize("NEMListView")
   ScrollView1.Panel.AddView(NEMListView, 5, 5, 100%x,10000%y)
   'NEMListView.TwoLinesLayout 
   Dim Label1, Label2 As Label
   Label1.Initialize ("")
   Label2.Initialize ("")
   
   NEMListView.TwoLinesLayout.ItemHeight = 50
   Label1 = NEMListView.TwoLinesLayout.Label 
   If DeviceType = "3" Then
   Label1.TextSize = 16
   Else
   Label1.TextSize = 12
   End If
   Label2.TextColor = Colors.White 
   Label2 = NEMListView.TwoLinesLayout.SecondLabel 
   If DeviceType = "3" Then
   Label2.TextSize = 14
   Else
   Label2.TextSize = 10
   End If
   Label2.TextColor = Colors.Yellow 
   
' NEM-Liste darstellen
   NEMListView.AddTwoLines2 ("NEM 001 Einführung in die NEM","D 1983",1)
...
...
...
...

If i change the 10000%y) to 100%, only a few items from the list will be displayed - but even now with over 2000dip oder %y not all items are displayed ?
 

GMan

Well-Known Member
Licensed User
Longtime User
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
:confused: One HEIGHT problem solved, the next one appears.

In my listview are items declared like this
B4X:
NEMListView.AddTwoLines2 ("NEM 001 Einführung in die NEM","D 1983",1)
NEMListView.AddTwoLinesAndBitmap2 ("NEM 801 A Eisenbahn-Epochen in Österreich","E 2008",BitmapA,102)

The Textsize of the 2 Labels (Label and SecondLabel) of each ListViewItem are set, depending on the resolution of the device - this works fine.
B4X:
Dim Label1, Label2 As Label
   Label1.Initialize ("")
   Label2.Initialize ("")
   
   NEMListView.TwoLinesLayout.ItemHeight = 50
   Label1 = NEMListView.TwoLinesLayout.Label 
   If DeviceType = "3" Then
   Label1.TextSize = 16
   Else
   Label1.TextSize = 12
   End If
   Label1.TextColor = Colors.White 
   
   Label2 = NEMListView.TwoLinesLayout.SecondLabel 
   If DeviceType = "3" Then
   Label2.TextSize = 14
   Else
   Label2.TextSize = 10
   End If
   Label2.TextColor = Colors.Yellow

But, if i mix these two kinds of items, the textsize of the Labels with BitMap is not the same as of the other labels - so now, on smaller devices the text will be cut off if the textparts are longer.

How can i solve this problem - is there an additional parameter for items with Bitmap ?

Attached is a screenshot from a 7" device - the layout fits on a 9" and 10"
 

Attachments

  • errorListView1.jpg
    errorListView1.jpg
    90.1 KB · Views: 166
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Setting properties for TwoLinesLayout doesn't set the same for two lines and bitmap.
You must set these properties seperately with TwoLinesAndBitmap !

Try tis code:
B4X:
NEMListView.TwoLinesLayout.ItemHeight = 50
NEMListView.TwoLinesAndBitmap.ItemHeight = 50
If DeviceType = "3" Then
    NEMListView.TwoLinesLayout.Label.TextSize = 16
    NEMListView.TwoLinesLayout.SecondLabel .TextSize = 14
    NEMListView.TwoLinesAndBitmap.Label.TextSize = 16
    NEMListView.TwoLinesAndBitmap.SecondLabel .TextSize = 14
Else
    NEMListView.TwoLinesLayout.Label.TextSize = 14
    NEMListView.TwoLinesLayout.SecondLabel .TextSize = 10
    NEMListView.TwoLinesAndBitmap.Label.TextSize = 14
    NEMListView.TwoLinesAndBitmap.SecondLabel .TextSize = 10
End If
NEMListView.TwoLinesLayout.Label.TextColor = Colors.White 
NEMListView.TwoLinesLayout.SecondLabel.TextColor = Colors.Yellow
NEMListView.TwoLinesAndBitmap.Label.TextColor = Colors.White 
NEMListView.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Yellow
Best regards.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Vielen Dank Klaus :sign0087:
 
Upvote 0
Top