Search code examples
androidimeandroid-input-methodcustom-keywordinputconnection

input connection-how to delete selected text?


I made a custom keyboard for android. When I press backspace button of my keyboard I use

getCurrentInputConnection().deleteSurroundingText(1, 0);

to delete one letter from the input field. But when I select some text and then press the backspace button, the selected text is not deleted. What method in input connection should I use so that selected text is also deleted from my keyboard when I press the backspace button?


Solution

  • Call getCurrentInputConnection().commitText("",1);