Don't use ListView.
Use xCustomListView - it is more powerful, easier to work with and cross platform.
Use xCustomListView - it is more powerful, easier to work with and cross platform.
Last edited:
You can change the properties Left, Top, Width and Height of all three views in the ListView items.
ListView1.TwoLinesAndBitmap.Label.Top etc
ListView1.TwoLinesAndBitmap.SecondLabel.Top etc
ListView1.TwoLinesAndBitmap.Bitmap.Top etc
Make sure that ListView1.TwoLinesAndBitmap.ItemHeight is set according to the heights of the internal views.
ListView1.TwoLinesAndBitmap.ItemHeight = 200dip
ListView1.TwoLinesAndBitmap.Bitmap.Height = 50
Sorry, it's ListView1.TwoLinesAndBitmap.ImageView and not ListView1.TwoLinesAndBitmap.Bitmap.
Sub Activity_Create(FirstTime As Boolean)
ListView1.Initialize("ListView1")
Dim GD As GradientDrawable
GD.Initialize("TR_BL", Array As Int(Colors.White, Colors.LightGray))
Activity.Background = GD
ListView1.ScrollingBackgroundColor = Colors.Transparent
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets, "Pic1.jpg")
Dim Bitmap2 As Bitmap
Bitmap2.Initialize(File.DirAssets, "Pic2.jpg")
Dim Bitmap3 As Bitmap
Bitmap3.Initialize(File.DirAssets, "Pic3.jpg")
Dim Bitmap4 As Bitmap
Bitmap4.Initialize(File.DirAssets, "Pic4.jpg")
Dim Bitmap5 As Bitmap
Bitmap5.Initialize(File.DirAssets, "Pic5.jpg")
ListView1.TwoLinesAndBitmap.ItemHeight = 160dip
ListView1.TwoLinesAndBitmap.ImageView.Height = 150dip
ListView1.TwoLinesAndBitmap.ImageView.Width = 150dip
ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Blue
ListView1.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Cyan
ListView1.SingleLineLayout.ItemHeight = 100dip
ListView1.SingleLineLayout.Label.TextSize = 20
ListView1.SingleLineLayout.Label.TextColor = Colors.Blue
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView1.FastScrollEnabled = True
For i = 1 To 5
ListView1.AddTwoLinesAndBitmap("Machine #" & i, "This is the second line.", Bitmap1)
ListView1.AddTwoLinesAndBitmap("Machine #" & i, "This is the second line.", Bitmap2)
ListView1.AddTwoLinesAndBitmap("Machine #" & i, "This is the second line.", Bitmap3)
ListView1.AddTwoLinesAndBitmap("Machine #" & i, "This is the second line.", Bitmap4)
ListView1.AddTwoLinesAndBitmap("Machine #" & i, "This is the second line.", Bitmap5)
Next
Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
End Sub
Sub Activity_Create(FirstTime As Boolean)
ListView1.Initialize("ListView1")
Dim GD As GradientDrawable
GD.Initialize("TR_BL", Array As Int(Colors.White, Colors.LightGray))
Activity.Background = GD
ListView1.ScrollingBackgroundColor = Colors.Transparent
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets, "Pic1.jpg")
Dim Bitmap2 As Bitmap
Bitmap2.Initialize(File.DirAssets, "Pic2.jpg")
Dim Bitmap3 As Bitmap
Bitmap3.Initialize(File.DirAssets, "Pic3.jpg")
Dim Bitmap4 As Bitmap
Bitmap4.Initialize(File.DirAssets, "Pic4.jpg")
Dim Bitmap5 As Bitmap
Bitmap5.Initialize(File.DirAssets, "Pic5.jpg")
ListView1.TwoLinesAndBitmap.ItemHeight = 160dip
ListView1.TwoLinesAndBitmap.ImageView.Height = 150dip
ListView1.TwoLinesAndBitmap.ImageView.Width = 150dip
ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Blue
ListView1.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Cyan
ListView1.SingleLineLayout.ItemHeight = 100dip
ListView1.SingleLineLayout.Label.TextSize = 20
ListView1.SingleLineLayout.Label.TextColor = Colors.Blue
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView1.FastScrollEnabled = True
ListView1.AddTwoLinesAndBitmap("Machine #1", "This is the second line.", Bitmap1)
ListView1.AddTwoLinesAndBitmap("Machine #2", "This is the second line.", Bitmap2)
ListView1.AddTwoLinesAndBitmap("Machine #3", "This is the second line.", Bitmap3)
ListView1.AddTwoLinesAndBitmap("Machine #4", "This is the second line.", Bitmap4)
ListView1.AddTwoLinesAndBitmap("Machine #5", "This is the second line.", Bitmap5)
Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
End Sub
B4X:Sub Activity_Create(FirstTime As Boolean) ListView1.Initialize("ListView1") Dim GD As GradientDrawable GD.Initialize("TR_BL", Array As Int(Colors.White, Colors.LightGray)) Activity.Background = GD ListView1.ScrollingBackgroundColor = Colors.Transparent Dim Bitmap1 As Bitmap Bitmap1.Initialize(File.DirAssets, "Pic1.jpg") Dim Bitmap2 As Bitmap Bitmap2.Initialize(File.DirAssets, "Pic2.jpg") Dim Bitmap3 As Bitmap Bitmap3.Initialize(File.DirAssets, "Pic3.jpg") Dim Bitmap4 As Bitmap Bitmap4.Initialize(File.DirAssets, "Pic4.jpg") Dim Bitmap5 As Bitmap Bitmap5.Initialize(File.DirAssets, "Pic5.jpg") ListView1.TwoLinesAndBitmap.ItemHeight = 160dip ListView1.TwoLinesAndBitmap.ImageView.Height = 150dip ListView1.TwoLinesAndBitmap.ImageView.Width = 150dip ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Blue ListView1.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.CENTER ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Cyan ListView1.SingleLineLayout.ItemHeight = 100dip ListView1.SingleLineLayout.Label.TextSize = 20 ListView1.SingleLineLayout.Label.TextColor = Colors.Blue ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER ListView1.FastScrollEnabled = True ListView1.AddTwoLinesAndBitmap("Machine #1", "This is the second line.", Bitmap1) ListView1.AddTwoLinesAndBitmap("Machine #2", "This is the second line.", Bitmap2) ListView1.AddTwoLinesAndBitmap("Machine #3", "This is the second line.", Bitmap3) ListView1.AddTwoLinesAndBitmap("Machine #4", "This is the second line.", Bitmap4) ListView1.AddTwoLinesAndBitmap("Machine #5", "This is the second line.", Bitmap5) Activity.AddView(ListView1, 0, 0, 100%x, 100%y) End Sub
hello, it is possible to place different background colors on different items?
best regardYes and no.
Yes, you can set an background to "All one-line-items".
Yes, you can set an background to "All two-line-items".
Yes, you can set an background to "All two-line-items with bitmaps".
No, you cannot set a background ONLY for one or more spezific items.
ListView1.TwoLinesAndBitmap.ImageView.Left = ListView1.Width - ListView1.TwoLinesAndBitmap.ImageView.Width
ListView1.TwoLinesAndBitmap.Label.Left = 0
ListView1.TwoLinesAndBitmap.Label.Width = ListView1.TwoLinesAndBitmap.ImageView.Left
ListView1.TwoLinesAndBitmap.SecondLabel.Left = 0
ListView1.TwoLinesAndBitmap.SecondLabel.Width = ListView1.TwoLinesAndBitmap.ImageView.Left
ListView1.TwoLinesAndBitmap.ImageView.Left = 100%x - 50dip
ListView1.TwoLinesAndBitmap.Label.Left = 0
ListView1.TwoLinesAndBitmap.Label.Width = 100%x - 50dip
ListView1.TwoLinesAndBitmap.SecondLabel.Left = 0
ListView1.TwoLinesAndBitmap.SecondLabel.Width = 100%x - 50dip
StorList.TwoLinesLayout.Label.TextColor=Colors.Black
StorList.TwoLinesLayout.Label.TextSize=14
StorList.TwoLinesLayout.SecondLabel.TextSize=12
StorList.TwoLinesLayout.ItemHeight=70dip
StorList.AddTwoLines(CAMqty.SelectedItem & " camera(s): " & CAMres.SelectedItem & ", " & VIDcompression.selecteditem & " @" & FPSqty.SelectedItem & "FPS", StorageDays.SelectedItem & " Days Storage = " & StorageSpace.Text & "GB, " & Bandwidth.Text & "Mbit/s" )
Sub Globals
Dim ltvTest1, ltvTest2 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
InitListView
End Sub
Sub InitListView
Dim i As Int
Dim LineWidth = 3dip As Int
Dim LineWidth_2 = Max(1, LineWidth / 2)
ltvTest2.SingleLineLayout.Label.Left = LineWidth
ltvTest2.SingleLineLayout.Label.Width = ltvTest2.Width - 2 * LineWidth
ltvTest2.SingleLineLayout.Label.Top = LineWidth_2
ltvTest2.SingleLineLayout.Label.Height = ltvTest2.SingleLineLayout.ItemHeight - LineWidth_2
ltvTest2.SingleLineLayout.Label.Color = Colors.White
ltvTest2.SingleLineLayout.Label.TextColor = Colors.Black
For i = 0 To 20
ltvTest1.AddSingleLine("Test "& i)
ltvTest2.AddSingleLine("Test "& i)
Next
End Sub