Hi everyone. I have a problem with B4XLongTextTemplate in my application. In my app, information is read from a database and displayed in B4XLongTextTemplate. The problem is that the text is not displayed in full. In the attached file, I put a piece of text from my database into the txt file, and the text is displayed in the B4XLongTextTemplate, but the text is not displayed completely. All the texts in the database have the same problem. I would be very grateful if you could help me solve this problem.
For some reason the text measurement isn't accurate. You can increase the height with:
B4X:
Sub Button1_Click
Dim s As B4XLongTextTemplate
s.Initialize
s.Text=File.ReadString(File.DirAssets,"text.txt")
Dim rs As Object = dialog.ShowTemplate(s,"OK","","")
s.CustomListView1.AnimationDuration = 0
Dim lbl As B4XView = s.CustomListView1.GetPanel(0).GetView(0)
lbl.SetTextAlignment("TOP","CENTER")
lbl.Height = lbl.Height + 80dip
s.CustomListView1.ResizeItem(0, lbl.Height)
wait for (rs) complete (r As Int)
End Sub
For some reason the text measurement isn't accurate. You can increase the height with:
B4X:
Sub Button1_Click
Dim s As B4XLongTextTemplate
s.Initialize
s.Text=File.ReadString(File.DirAssets,"text.txt")
Dim rs As Object = dialog.ShowTemplate(s,"OK","","")
s.CustomListView1.AnimationDuration = 0
Dim lbl As B4XView = s.CustomListView1.GetPanel(0).GetView(0)
lbl.SetTextAlignment("TOP","CENTER")
lbl.Height = lbl.Height + 80dip
s.CustomListView1.ResizeItem(0, lbl.Height)
wait for (rs) complete (r As Int)
End Sub
Thank you. One point that may be interesting is that I tested my app on an old phone (Samsung j7) and there were no problems and all the text inside the B4XLongTextTemplate was displayed. But on newer phones, the text is not displayed in full. Regarding the solution you provided, I must mention that in my app, the text is read from the database and displayed in the B4XLongTextTemplate . Each field of each record has different lengths. Will all the text be displayed by adding a fixed value to the height?
Based on your answer in post #5, maybe you are better off usibg xCustomListview using AddTextItem than using B4XLongTextTemplate. With xCustomListview, yo can scroll each record, rather than showing one record at a time. If the text does not show its entirety, then you can still use Erel's recommendation in post #6
If you are interested in xClv I can post for you a project that uses xCustomListview scrolling panels to give you an idea on how it would work compared to B4XLongText. Check this screenshot first. If you are good with what you currently have, then stay with it. .
You probably have to accept that the text will not be displayed in its entirety. This shouldn't be a problem for the user because you can scroll the text...
I am aware that B4XLongTextTemplate is based on xClv. But the reason I recommend an xClv is because the OP mentions that his text comes from a database. Therefore, his table must have a lot more than one record and each record has a different length. With xClv he can scroll down many items,. It gives him an added dimension over B5XLongText. isn't that the case.
If you are interested in xClv I can post for you a project that uses xCustomListview scrolling panels to give you an idea on how it would work compared to B4XLongText. Check this screenshot first. If you are good with what you currently have, then stay with it. View attachment 148634.