Android Question Text Alignment in B4XLongTextTemplate

M.Amini

Member
hi. how can i change text alignment in B4XLongTextTemplate. i need to change alignment from left to right.
 

Mahares

Expert
Licensed User
Longtime User
Why is it that this below works:
B4X:
Dim rs As Object = Dialog.ShowTemplate(LongTextTemplate, "", "", "Cancel")
LongTextTemplate.CustomListView1.GetPanel(0).GetView(0).SetTextAlignment("TOP", "RIGHT")
Wait For (rs) Complete (Result As Int)

But this below does not:
B4X:
LongTextTemplate.CustomListView1.GetPanel(0).GetView(0).SetTextAlignment("TOP", "RIGHT")
Dialog.ShowTemplate(LongTextTemplate, "OK", "", "")
It crashes: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
Is that because of the internal layout that needs to be loaded.

This below works in changing the font of the label, but does not change the alignment to right:
B4X:
Dim e As B4XView=LongTextTemplate.CustomListView1.DesignerLabel
    Dim f As B4XFont =XUI.CreateDefaultBoldFont(28)
    e.Font = f
    e.SetTextAlignment("TOP", "RIGHT")
    Dialog.ShowTemplate(LongTextTemplate, "OK", "", "")
Boy, am I foggy on this or what?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
e views are created when calling ShowTemplate (at it returns an object to use for the waitfor)
In that case why does the font change but the alignment does not take effect in this below code. Try it:
B4X:
LongTextTemplate.Text = $"B4X is a great development tool, Manfred is instrumental in making it better."$
    Dim e As B4XView=LongTextTemplate.CustomListView1.DesignerLabel
    Dim f As B4XFont =XUI.CreateDefaultBoldFont(28)
    e.Font = f
    Dim rs As Object = Dialog.ShowTemplate(LongTextTemplate, "", "", "Cancel")
    e.SetTextAlignment("TOP", "RIGHT")
    Wait For (rs) Complete (Result As Int)
 
Upvote 0

M.Amini

Member
Thanks. i have a problem with B4XLongTextTemplate. I tested my app on two different devices. There is no problem in one device, but in other device, the text inside the B4XLongTextTemplate is not fully displayed. Where is the problem and how can I fix this problem?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…