Android Question display full text in B4XLongTextTemplate

M.Amini

Member
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.
 

Attachments

  • b4xlongtext.zip
    9.8 KB · Views: 135
Solution
You will need to test it.

A better solution might be something like:
B4X:
lbl.Height = lbl.Height * 1.2

And remember that it isn't too bad if the list is taller than it really needs to be.

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 
Last edited:
Upvote 0

M.Amini

Member
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?
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
the text is read from the database and displayed in the B4XLongTextTemplate . Each field of each record has different lengths.
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
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
the text is read from the database and displayed
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.
1702421401986.png
.
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
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...
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
4XLongTextTemplate is based on xCLV and is scrollable.
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.
 
Upvote 0

M.Amini

Member
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.
Hello, I'm sorry, I just saw your message, I would be happy to see your solution, please send the file, thank you.
 
Upvote 0
Top