I use EditText to input some information, and I setText in EditText.
But I have a problem, when EditText display, the keyboard display too.
when I input text it will add text in first not after text that I set before!
this is my editText with keyboard
[here is keyboard input text]example <- this example is my setText
I need to set up input text after my text like this
example[here is keyboard input text]
Thanks for help ....
for that you can add a textChanged listener to edit text and you can add your default text at your desired index.(i mean you override these methods to implement your logic)
You should set the selection to the end as follows:
Note: If you need a space, then update your
setText
as follows:editText.setText("example ");
I think you need setSelection to move to end of your text
You can use the
setSelection(int index)
method on yourEditText
to move the cursor to the end of theEditText
.So for example:
That will set the cursor in the
EditText
to be at the last position of the text in theEditText
.Set a default text in your edittext widget and in your main class, impletement its text change listener and for the sake of convenience i have put a print statement to see the text entered