Android Question [Solved] Border and corner in CustomlistView.AddTextItem

asales

Expert
Licensed User
Longtime User
I want to create a list - like the example below - and the AddTextItem is very nice, because it adjust automatically the text.

My problem is create a border and a corner in this option.

Is possible or do I need create a new layout - with a panel and a label - load the text and adjust manually the height?

Thanks in advance for any tip.

 

mangojack

Expert
Licensed User
Longtime User
After loading the ClV , run the following ...

B4X:
For i = 0 To clv1.Size -1
        Dim p As B4XView = clv1.GetPanel(i)
        p.SetColorAndBorder(xui.Color_White, 2, xui.Color_Gray, 10)
    Next

This could also be done after loading each item / row

Note : Make sure to set the Divider Color to Transparent in the Designer
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
?
Panel = B4XView
B4X:
   For i = 0 To clv1.Size -1
        CustomListView1.GetRawListItem(i).Panel.SetColorAndBorder(xui.Color_White, 1dip, xui.Color_Black, 10dip)
    Next
 
Last edited:
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
What is this ??

I have been struggling with layout / add panel to achieve similar objective, keeping in mind :AddTextItem can not do this, as Erel as advised many times.
Now you all are giving simple solution for it, in :AddTextItem itself !

Who will pay for my lost time and energy ?
?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I think what is confusing about calling it AddTextItem is the word ‘Text’. When you see ‘Text’, you think it is limited in scope. I would have called it AddImplicitItem or AddImplicitPanel. Everything related to xClv involves panels.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Yes. The big plus of :AddTextItem is
the AddTextItem is very nice, because it adjust automatically the text.

But now we can use the adjusted panel, is icing on the cake
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
What AddItemText can't do?

It seems clear to me: Add allows you to add an Item consisting of a panel containing any number of views, AddItemText adds a "pre-packaged" Item, consisting of a panel and a label.
Maybe I did not knew how to use "this" panel.
But now I know ? Thanks to you all.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
B4X:
    Dim ItemsColor(2) As Int = Array As Int(xui.Color_Yellow, xui.Color_Blue)
    For i = 1 To 10
        CustomListView1.AddTextItem("item " & i, i)
       
        Dim Item As CLVItem = CustomListView1.GetRawListItem(CustomListView1.Size - 1)
        Item.Panel.SetColorAndBorder(ItemsColor(i Mod 2), 1dip, xui.Color_Black, 10dip)
       
        Dim bxTextView As B4XView = Item.Panel.GetView(0).GetView(0)
        bxTextView.TextColor = ItemsColor((i + 1) Mod 2)
    Next

 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
padding and height settings?

????

???
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You can also add text as CSBuilder:
B4X:
Dim cs As CSBuilder
        cs.Initialize.Size(30).Typeface(Typeface.MONOSPACE)
        cs.Alignment("ALIGN_CENTER").Append("item " & i).Append(CRLF).Image(LoadBitmap(File.DirAssets, "ua.png"), 200dip, 100dip, False).Append(CRLF).PopAll
        CustomListView1.AddTextItem(cs, i)
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Add:
B4X:
bxTextView.As(Label).Padding = Array As Int(10dip, 5dip, 10dip, 5dip)


Height of ? Item?
see:
Height of ? Item?
B4X:
    For i = 0 To clv1.Size -1
        Dim item As CLVItem = clv1.GetRawListItem(i)
        item.Panel.SetColorAndBorder(xui.Color_White, 2dip, xui.Color_DarkGray, 6dip)

        Dim lbl As B4XView = item.Panel.GetView(0).GetView(0)
        lbl.As(Label).Padding = Array As Int (5dip, 5dip, 5dip, 5dip)
    Next

 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I think AddTextItem sets the height equal for all items, based on the xCLV TextSize set in the Designer and on a single line of text.
I don't think you can change the height of these items at runtime; in this case, it is better to use Add and create custom items.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…