I have a EditText box in which i want to control the cursor and modify the text programmatically
- I have 12 button keypad made using 12 buttons in a GridView. With each button press I have a specific text which is to be inserted in EditText box at cursor position. For this i need cursor position so that i can insert the my custom text in the EditText view
- I have two buttons for moving cursor position left/right by one character. Alternatively the cursor can also be set by touching EditText view (as EditText is supposed to behave)
- Also i want the current position of cursor in EditText whenever Cursor position changes (I think i have to implement some kind of interface but i dont know how)
What i have tried so far
- I am storing the key presses in an
ArrayList<String>
- I am setting the
edittext.setText(String)
everytime a key is pressed - can get the editable text through
getText()
butsetText()
only accepts strings.
Hence i am confused. What should i do to fulfill all my requirements.
PS: I am a Android beginner, and am making my 2nd app (which is a scientific calculator if it helps)
also if anyone volunteers to review my code, I'll be deeply obliged to him