Is there a way to specify the display text of a listview item?

Penko

Active Member
Licensed User
Longtime User
Hello,

I have the following problem. My listView's value is a special TYPE and what surprised me is that the listview automatically detects that the value is NOT a simple variable object and displays the key value because it is a string. Is there any way to set the displayed value explicitly?

Sent from my HTC Desire using Tapatalk
 

klaus

Expert
Licensed User
Longtime User
Did you have a look at AddSingleLine2(Text As String, ReturnValue As Object) ?
With the Addxxx2 methods you can specify the text(s) and a specific return object.

I would suggest you to download agrahams B4AHelpViewer it's very helpfull.

Best regards.
 
Last edited:
Upvote 0

Penko

Active Member
Licensed User
Longtime User
Danke, Klaus! I didn't know this general explanation of "2" methods and was reading about them on demand.

Klaus, it seems I am wrong. I have implemented the Sub with the "2" method. Here is my code:

B4X:
Sub listAddItem(key As String, value As WORD)

   listViewMain.AddSingleLine2(key, value)
   
   If(Common.debug_mode) Then
      Common.LogT("This is added: KEY(" & key & "), VALUE(" & value & ")", "")
   End If
   
End Sub

Now, here is what I noticed:
  • if your value is String ==> listview display text = value
  • if your value is WORD and key is string ==> listview display text = key
  • if your value is WORD and your key is WORD => one of them is shown in some stringified way

I may not be correct but this is what I discovered.
 
Last edited:
Upvote 0
Top