Didier9 Well-Known Member Licensed User Longtime User Oct 15, 2023 #1 When adding a TwoLine item to a ListView, is there a way to have the top line left justified and the second line right-justified? I want to have text on the first line and a number on the second line and it would look better that way. TIA
When adding a TwoLine item to a ListView, is there a way to have the top line left justified and the second line right-justified? I want to have text on the first line and a number on the second line and it would look better that way. TIA
William Lancee Well-Known Member Licensed User Longtime User Oct 15, 2023 #2 Put two labels in the panel and set their alignment and content as you like. That is - if you use CLV. Upvote 0
Put two labels in the panel and set their alignment and content as you like. That is - if you use CLV.
toby Well-Known Member Licensed User Longtime User Oct 15, 2023 #3 Below is the code using XCustomListView which is recommended B4X: Copy Dim csb As CSBuilder csb.Initialize.Alignment("ALIGN_NORMAL").Append("First line").Append(CRLF).Pop csb.Alignment("ALIGN_OPPOSITE").Append("123").PopAll clv1.AddTextItem(csb, csb) Upvote 0
Below is the code using XCustomListView which is recommended B4X: Copy Dim csb As CSBuilder csb.Initialize.Alignment("ALIGN_NORMAL").Append("First line").Append(CRLF).Pop csb.Alignment("ALIGN_OPPOSITE").Append("123").PopAll clv1.AddTextItem(csb, csb)
Didier9 Well-Known Member Licensed User Longtime User Oct 15, 2023 #4 Thank you, I guess that's why the CustomListView exists Upvote 0
toby Well-Known Member Licensed User Longtime User Oct 15, 2023 #5 If you still want to use ListView, B4X: Copy Dim csb1, csb2 As CSBuilder csb1.Initialize.Alignment("ALIGN_NORMAL").Append("First line").PopAll csb2.initialize.Alignment("ALIGN_OPPOSITE").Append("123").PopAll lv.AddTwoLines(csb1, csb2) Upvote 0
If you still want to use ListView, B4X: Copy Dim csb1, csb2 As CSBuilder csb1.Initialize.Alignment("ALIGN_NORMAL").Append("First line").PopAll csb2.initialize.Alignment("ALIGN_OPPOSITE").Append("123").PopAll lv.AddTwoLines(csb1, csb2)
DonManfred Expert Licensed User Longtime User Oct 15, 2023 #6 It also works with Listview. But it is recommended to use xclv instead. B4X: Copy ListView1.TwoLinesLayout.Label.Gravity = Gravity.LEFT ListView1.TwoLinesLayout.Label.TextColor = Colors.Black ListView1.TwoLinesLayout.SecondLabel.Gravity = Gravity.RIGHT ListView1.TwoLinesLayout.SecondLabel.TextColor = Colors.Red ListView1.AddTwoLines("Bla","1") ListView1.AddTwoLines("Blub","2") Upvote 0
It also works with Listview. But it is recommended to use xclv instead. B4X: Copy ListView1.TwoLinesLayout.Label.Gravity = Gravity.LEFT ListView1.TwoLinesLayout.Label.TextColor = Colors.Black ListView1.TwoLinesLayout.SecondLabel.Gravity = Gravity.RIGHT ListView1.TwoLinesLayout.SecondLabel.TextColor = Colors.Red ListView1.AddTwoLines("Bla","1") ListView1.AddTwoLines("Blub","2")
Didier9 Well-Known Member Licensed User Longtime User Oct 15, 2023 #7 Thank you Don, that's exactly what I was looking for. Upvote 0
M Mahares Expert Licensed User Longtime User Oct 15, 2023 #8 Didier9 said: I guess that's why the CustomListView exists Click to expand... Not really. This is not to entice you to use xClv, because everyone has their own reason for using what they want to use, but you can see that the syntax can be simpler for xClv than Listview Code: Copy lbl1.Text=$"Didier9 ${x} From Florida, America"$ 'The 2 labels: lbl1, lb2 are declared as B4Xviews lbl2.SetTextAlignment("CENTER", "RIGHT") lbl2.Text=$"${Power(x,3)}"$ Upvote 0
Didier9 said: I guess that's why the CustomListView exists Click to expand... Not really. This is not to entice you to use xClv, because everyone has their own reason for using what they want to use, but you can see that the syntax can be simpler for xClv than Listview Code: Copy lbl1.Text=$"Didier9 ${x} From Florida, America"$ 'The 2 labels: lbl1, lb2 are declared as B4Xviews lbl2.SetTextAlignment("CENTER", "RIGHT") lbl2.Text=$"${Power(x,3)}"$
Didier9 Well-Known Member Licensed User Longtime User Oct 20, 2023 #9 Mahares said: Not really. This is not to entice you to use xClv, because everyone has their own reason for using what they want to use, but you can see that the syntax can be simpler for xClv than Listview Code: Copy lbl1.Text=$"Didier9 ${x} From Florida, America"$ 'The 2 labels: lbl1, lb2 are declared as B4Xviews lbl2.SetTextAlignment("CENTER", "RIGHT") lbl2.Text=$"${Power(x,3)}"$ View attachment 146892 Click to expand... Thank you, yes this particular operation is simpler, but I am not familiar with the xClv and my app at the moment uses the regular ListView so I would have to do more research how to use it and possibly more changes to the existing code, which would certainly be a worthwhile endeavor for the long term but it's getting in the way of what I am trying to do right now The app I am working on is 4-5 years old and I use it every day (expense tracker), I am just trying to add a bit of functionality. Upvote 0
Mahares said: Not really. This is not to entice you to use xClv, because everyone has their own reason for using what they want to use, but you can see that the syntax can be simpler for xClv than Listview Code: Copy lbl1.Text=$"Didier9 ${x} From Florida, America"$ 'The 2 labels: lbl1, lb2 are declared as B4Xviews lbl2.SetTextAlignment("CENTER", "RIGHT") lbl2.Text=$"${Power(x,3)}"$ View attachment 146892 Click to expand... Thank you, yes this particular operation is simpler, but I am not familiar with the xClv and my app at the moment uses the regular ListView so I would have to do more research how to use it and possibly more changes to the existing code, which would certainly be a worthwhile endeavor for the long term but it's getting in the way of what I am trying to do right now The app I am working on is 4-5 years old and I use it every day (expense tracker), I am just trying to add a bit of functionality.