Android Question Change Listview item

fernando.oliboni

Active Member
Licensed User
Longtime User
How can I change the font color and size of the last item on the list?


B4X:
lista_orcamentos.AddTextItem("Voltar para Tela de Orçamentos" , "Voltar para Tela de Orçamentos")
 

Mahares

Expert
Licensed User
Longtime User
How can I change the font color and size of the last item on the list?
When you use listview or customlistview with the AddTextItem approach, you cannot selectively change the color of one item. To be able to do it, you have to switch to using customlistview with the items layout approach.
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Try with CSbuilder

 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
There are several ways to get a different color for a native ListView item.

Using CSBuilder is one way.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Using CSBuilder is one way.
Ok. I investigated it further Here is the code for displaying the last item in blue:
B4X:
Dim j As Int    
    For Each s As String In MyList
        clv1.AddTextItem(s, s)
        If j=MyList.Size -1 Then
            Dim cs As CSBuilder
            cs.Initialize.Bold.size(40).color(Colors.Blue).Append($"${s}"$).popall
            clv1.AddTextItem(cs, s)
        End If
        j=j+1
    Next
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
There isn't a single good reason to use ListView. Don't waste your time.
Although the OP used the word listview, I really think he meant and was using a customlistview. Take a look at his first post line of code. It is a customlistview line not listview line. That is why I posted the pertinent code in post #5 for an xClv he can use.
 
Upvote 0

fernando.oliboni

Active Member
Licensed User
Longtime User
[QUOTE = "Mahares, postagem: 780465, membro: 16350"]
Está bem. Eu investiguei mais aqui. Aqui está o código para exibir o último item em azul:
[código] Dim j As Int
For each s As String In MyList
clv1.AddTextItem (s, s)
Se j = MyList.Size -1 Then
Dim cs As CSBuilder
cs.Initialize.Bold.size (40) .color (Colors.Blue) .Append ($ "$ {s}" $). popall
clv1.AddTextItem (cs, s)
Fim se
j = j + 1
Próximo [/ code]
[/CITAR]



Muito obrigado pela atenção. Seu exemplo funcionou. Gostei da dica. Também irei dar uma olhada no xCustomListView como Erel sugere.
 
Upvote 0

fernando.oliboni

Active Member
Licensed User
Longtime User
[QUOTE = "Star-Dust, postagem: 780464, membro: 101440"]
Existem várias maneiras de obter uma cor diferente para um item ListView nativo.

Usar o CSBuilder é uma maneira.
[/ CITAR]

Thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are of course correct!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…