Android Question Inserting line break in EditText

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi,

I need to insert line break at cursor location in edit text. I dont know how to know the current cursor location.
Can anyone give a clue.

Thanks
Juzer
 

MicroDrie

Well-Known Member
Licensed User
Can you give use a clue about the component with the edit text? A small code example will help.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Its like user is editing long text in edittext at many places he wants to start new line. I want to give a button to click which will insert line break character at the cursor position.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can use something like this:

B4X:
Sub btnInsertLF_Click
    Private txt1, txt2 As String
    txt1 = txt.SubString2(0, edtText.SelectionStart)
    txt2 = txt.SubString(edtText.SelectionStart)
    txt = txt1 & CRLF & txt2
    edtText.Text = txt
    Log(edtText.SelectionStart)
End Sub
 
Upvote 0
Top