Android Question XcustomeListview and Maps Fragment

victormedranop

Well-Known Member
Licensed User
Longtime User
Hi, all. i am trying to make a card view with different maps fragment with different locations.
trying to but with no luck, if someone point me in the right directin.

thanks,

Victor

B4X:
Private Sub CreateItem(Width As Int, Title As String, Image As String, Content As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    Dim height As Int = 280dip
    If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 310dip
    p.SetLayoutAnimated(0, 0, 0, Width, height)
    p.LoadLayout("Card1")
    
    lblTitle.Text = Title
    lblContent.Text = Content
    SetColorStateList(lblAction1, xui.Color_LightGray, lblAction1.TextColor)
    SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
    'ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, Image, ImageView1.Width, ImageView1.Height, True))
    ImageView1.SetBitmap(xui.LoadBitmap(File.DirAssets, Image)) ',50%x, ImageView1.Height, True))
    Return p
End Sub
 

Mahares

Expert
Licensed User
Longtime User
trying to but with no luck, if someone point me in the right directin.

You can do something like this where you put you map fragments in a list. You can add lazy loading too if you want:

B4X:
Private height As Int  'in globals

Dim MyList As List =Array ("map0.png", "map1.png", "map2.png", "map3.png")  'in Activity_Create of B4Xpage_Create
   'If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then
        'height = 310dip
   ' Else
        'height  = 280dip
    'End If
    height = IIf(GetDeviceLayoutValues.ApproximateScreenSize < 4.5, 310dip, 280dip)  
    For i = 0 To 3
        CLV1.Add(CreateItem (CLV1.AsView.Width, $"This is Title #${i}"$, MyList.Get(i), $"This is content #${i}"$) , i)
    Next

Private Sub CreateItem(Width As Int, Title As String, Image As String, Content As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, height)
    p.LoadLayout("Card1")
  
    lblTitle.Text = Title
    lblContent.Text = Content
    ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, Image, ImageView1.Width, ImageView1.Height, True))
  
    SetColorStateList(lblAction1, xui.Color_LightGray, lblAction1.TextColor)
    SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
    Return p
End Sub

If you want to be fancy and experiment with IIF, you can do this:
B4X:
height = IIf(GetDeviceLayoutValues.ApproximateScreenSize < 4.5, 310dip, 280dip)
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:

We can go another step and remove the invisible items. This can be relevant if the items include large bitmaps or other "heavy" UI elements.

or

[B4X] B4XTable
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
I'm not sure that it is a good idea to add many maps. Will probably be better to reuse the maps with the VisibleRangeChanged event.

Anyway, you should add the map in the cards layout file.
Eso mismo pense, That's what I thought. I put an image (blur) to start another activit, an display the map.
 
Upvote 0
Top