B4J Question TableView multiline cell?

Bruce Axtens

Active Member
Licensed User
Longtime User
In my log reader, I have log items with 4 columns: status, path, datetime, message. The message may be multiline with CR used as the line delimiter. How do I get these multiline cells to appear in full rather than just the first line? Currently I'm just using this to load up the tableview:

Bruce/bugmagnet

B4X:
           Dim flines As List
           flines.Initialize2(Regex.Split("\x0D\x0A", File.ReadString(fdir, flist.Get(f))))
           For j = 0 To flines.Size -1
               Dim Row() As Object = Regex.Split("\t", flines.Get(j))
               If Row.Length = 4 Then
                   TableView1.Items.Add(Row)
               End If
           Next
 

Bruce Axtens

Active Member
Licensed User
Longtime User
The latter. That is, how to add a multiline cell to TableView or how to format a cell from single line to multiline once placed in the row.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
    TableView1.Items.Add(CreateRow(Array As String($"sjdfklsjdklf
sd fjlksdfj lk
fwefwefwef"$, _
       "Second item")))

SS-2018-04-26_09.56.42.png


Based on the table example.
TableView Tutorial
 
Upvote 0

Bruce Axtens

Active Member
Licensed User
Longtime User
Wonderful. Worked well and so much more obviously than the XAML/C# approach I was trying yesterday and which forced back to B4J.

B4X:
Sub LoadFolders(fldrs As List)
	TableView1.Items.Clear
	For i = 0 To fldrs.Size-1
		Dim fdir As String
		fdir = fldrs.Get(i)
		LogDebug(fdir)
		Dim flist As List
		flist.Initialize2(File.ListFiles(fdir))
		For f = 0 To flist.Size -1
			Dim flines As List
			flines.Initialize2(Regex.Split("\x0D\x0A", File.ReadString(fdir, flist.Get(f))))
			For j = 0 To flines.Size -1
				Dim tabbed() As Object
				tabbed = Regex.Split("\t", flines.Get(j))
				If tabbed.Length = 4 Then
					Dim s As String
					s = tabbed(3)
					If s.IndexOf("\r") > -1 Then
						s = s.Replace("\r", "\r\n")
						tabbed(3) = s
					End If
					TableView1.Items.Add(tabbed)
				End If 
			Next
		Next
	Next
	
End Sub

Thank you.
 
Upvote 0

Bruce Axtens

Active Member
Licensed User
Longtime User
It's been well over a year since I last wrote anything intelligent in B4J. There are undoubtedly better ways of doing what I have been and LoadCSV looks like one of them. Thanks for the heads up.

Bruce/bugmagnet
 
Upvote 0

Bruce Axtens

Active Member
Licensed User
Longtime User
I'm not sure what your code does but it looks like it can be significantly simpler. If you are loading a TSV then you can use StringUtils.LoadCSV.

True, but what if you want to load a group of TSVs. How do you append the second lot of data after you've put in the first?
 
Upvote 0
Top