Android Question edittext multiline by code

DiegoTor

New Member
Licensed User
Hello, I have an issue when adding an edittext component by code.
I set wrap = true and singleLine = False, but it seems the multiline property is not activated. The text doesn´t wrap when exceeding the with of the edittext.
If someone has an idea what it may be or experienced the same issue and knows how to solve i´ll thank you.
 

DiegoTor

New Member
Licensed User
Hi, i think it's solved
The problem is that after adding the edittext the singleLine property is reset to True.
B4X:
Sub  GetEdit(tag As String, type As String, hint As String) As EditText
    Dim edit As EditText : edit.initialize("")
    edit .Tag = tag
    edit.Wrap = True
    edit.HintColor = Colors.Gray
    edit.Hint = hint
    edit.Gravity = Gravity.CENTER_VERTICAL
    edit.TextColor = Colors.Black
    edit.TextSize = 15
    Select  type
        Case "NUM"
            edit.InputType = edit.INPUT_TYPE_DECIMAL_NUMBERS
        Case "TEXT"
            edit.SingleLine = False 
            edit.InputType = edit.INPUT_TYPE_TEXT     
    End Select
    
    Return edit
End Sub

Sub LoadLayout
 
    Dim edit As EditText = GetEdit("comment", "TEXT", "Add comment")
    panel.AddView( edit, 16dip, 0, 50%x, 56dip)
    edit.SingleLine = False  'Set sigleLine to false after adding the view
End Sub
 
Upvote 0
Top