1. 程式人生 > >Android模仿軟鍵盤實現軟鍵盤的刪除功能(逐個刪除EditText的輸入元素)

Android模仿軟鍵盤實現軟鍵盤的刪除功能(逐個刪除EditText的輸入元素)

直接在刪除的點選事件里加入以下程式碼即可:

int  keyCode = KeyEvent.KEYCODE_DEL;
KeyEvent keyEventDown = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
KeyEvent keyEventUp = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
chat_editText.onKeyDown(keyCode, keyEventDown);
chat_editText.onKeyUp(keyCode, keyEventUp);