Android Question Attempt to enter two lines of text into B4XInputTemplate

toby

Well-Known Member
Licensed User
Longtime User
What I want to achieve:
1. The text area height to be increased to accommodate 2 lines of text
2. Enable Text wrapping
3. All text entered should be visible
4. The text field is as wide as the activity width.

Problems I'm facing:
1. There is some blank space above the text
2. Not all text entered are visible
3. The width of the input template is much shorter than that of the dialog.

Note: The max 200 chars limit is not written in stone. All I want is to be able to enter some text longer than the default input template can accommodate with word wrapping enabled.

Could someone show me what I did wrong, please?

TIA


To show two lines of text with wrapping enabled:
    Activity.LoadLayout("Layout")
    Dialog.Initialize(Activity)
    inputTemplate.Initialize
    Dialog.Title="Please enter text"
    rs=Dialog.ShowTemplate(inputTemplate, "OK", "", "CANCEL")
    Dialog.Base.Width=Dialog.Base.Width * 2
    Dialog.Base.Top=0
    Dialog.Base.Left=0
    Dim bft As EditText 'B4XFloatTextField
    bft=inputTemplate.TextField1
    bft.Width=Activity.Width
    bft.Height=bft.Height * 2
    bft.Wrap=True
    bft.TextColor=xui.Color_Magenta
    inputTemplate.lblTitle.Text="Max 200 characters"
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dialog.Show($"You entered: ${inputTemplate.Text}"$, "OK", "", "")
    End If
 

Attachments

  • InputTemplate2lines.jpg
    InputTemplate2lines.jpg
    61 KB · Views: 139

toby

Well-Known Member
Licensed User
Longtime User
My solution is to use customlayout as follows
B4X:
Sub ShowDialog
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 98%x, 300dip) 'set the content size
    p.LoadLayout("CustomLayout")
    Dim rs As ResumableSub = Dialog.ShowCustom(p, "Ok", "", "Cancel")
    Dim et As EditText=bftfDetail.TextField
    et.Wrap=True
    et.SingleLine=False
    
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        'do something
    End If
End Sub
 
Upvote 0
Top