Android Question some questions about editText

CN_guy

New Member
I'm a beginner.
I want to make an Android APP like CMD , but I have some questions .
I made a editText , I hope when I press Enter , I can't change the words before , so I think I can get EditText.SelectionStart , if it isn't in the end , the editText will not be change.
But this APP does not work properly ,I don't know why , could you teach me ?

B4X:
Sub Globals
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    EditText1.Height=100%y
    EditText1.Width=100%x
    EditText1.Left=Activity.Left
    EditText1.Top=Activity.Top
    EditText1.Color=Colors.Black
    EditText1.TextSize=13
    EditText1.Text="mini-CMD [v 1.1.1001]"& CRLF & "2018-1-10 N"
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
    Dim gb As Int = EditText1.SelectionStart
    If gb<EditText1.Text.Length Then
        EditText1.Text =Old
    End If
End Sub

I want like this
CMD.png



My english is not very well , thanks for your reading and help
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code is not needed:
B4X:
   EditText1.Height=100%y
    EditText1.Width=100%x
    EditText1.Left=Activity.Left
    EditText1.Top=Activity.Top
You should use anchors in the designer instead.

I think that it will be much simpler and work better if you use a multiline label for the "logs" and a single line EditText for the current line.
 
Upvote 0

CN_guy

New Member
I tried it.
Yes, it will be much simpler . But that's not the result I want , I can't select all the words(I maen select all ,both of multiline label and single line EditText ). This method is not good at all ,Thank you very much .
 
Upvote 0
Top