Android Question b4xdialog B4XLongTextTemplate Issue

bocker77

Active Member
Licensed User
Longtime User
I have the following code where I am trying to size the body of the message by the length of the text. I need to use a mono font so as to determine how to size it. While getting it to work for some reason there is extra spaces (between "the" and "Japan") and missing word ("of" after "control"). I am not sure if I am doing something wrong. I also will need to turn off scrolling but that is not in the below code yet.

B4X:
        csMsgText.Initialize.Typeface(fntMsgMono)
        csMsgText.Append("Confirm that the ").Bold.Color(HiLitePwr).Append(strPower).Pop
        csMsgText.Append(" Power is to take control of the territory ")
        csMsgText.Bold.Color(HiLiteTerr).Append(Territory.Name).PopAll
        Dialog.PutAtTop = True
        tmpLongText.mBase.Width = 360dip
        tmpLongText.CustomListView1.Base_Resize(356dip, 200dip)
        tmpLongText.Text = csMsgText
        iLen = csMsgText.Length
        Log(iLen)
        If iLen < 81 Then
            tmpLongText.mBase.Height = 90dip
        Else If iLen >= 81 And iLen <= 107 Then
            tmpLongText.mBase.Height = 125dip
        Else If iLen > 107 Then
            tmpLongText.mBase.Height = 150dip            
        End If
        Dim rsp As ResumableSub = Dialog.ShowTemplate(tmpLongText, "Yes", "No", "")
        Dim btnYes As B4XView = Dialog.GetButton(xui.DialogResponse_Positive)
        btnYes.SetBitmap(bmpBtnUp)
        Dim btnNo As B4XView = Dialog.GetButton(xui.DialogResponse_Negative)
        btnNo.SetBitmap(bmpBtnUp)
        Wait For (rsp) Complete (Result As Int)
        If Result = xui.DialogResponse_Positive Then
           ...
        End If

Screenshot attached.
 

Attachments

  • Screenshot_20240729-105409.png
    Screenshot_20240729-105409.png
    295.9 KB · Views: 66

bocker77

Active Member
Licensed User
Longtime User
I sort of kind of figured it out. If anyone else is interested here is the code. I changed "Confirm that the " to "Confirm that the" eliminating the space in the csbuilder text. For some reason this only occurs using the monospaced font. Doesn't happen if I go back to a proportional font like Serif. The text still doesn't fill the whole body of the dialog window but I can live with that.

B4X:
        csMsgText.Initialize.Typeface(fntMsgMono)
        csMsgText.Append("Confirm that the").Bold.Color(HiLitePwr).Append(strPower).Pop
        csMsgText.Append(" Power is to take control of the territory ")
        csMsgText.Bold.Color(HiLiteTerr).Append(Territory.Name).PopAll
        Dialog.PutAtTop = True
        tmpLongText.Text = csMsgText
        iLen = csMsgText.Length
        If iLen < 81 Then
            tmpLongText.Resize(340dip, 90dip)
        Else If iLen >= 81 And iLen <= 107 Then
            tmpLongText.Resize(340dip, 125dip)
        Else If iLen > 107 Then
            tmpLongText.Resize(340dip, 150dip)
        End If
 
Upvote 0
Top