Java Code Examples for android.widget.EditText#dispatchKeyEvent()
The following examples show how to use
android.widget.EditText#dispatchKeyEvent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputHelper.java From FlowGeek with GNU General Public License v2.0 | 5 votes |
public static void backspace(EditText input) { if (input == null) { return; } KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); input.dispatchKeyEvent(event); }
Example 2
Source File: L3PostActivity.java From smart-farmer-android with Apache License 2.0 | 5 votes |
@Override public void onFaceItemClick(FacePanelView view, String face, int faceId) { View focusView = getCurrentFocus(); if (focusView != null && focusView instanceof EditText) { EditText editText = (EditText) focusView; int index = editText.getSelectionStart(); if (FacePanelView.KEY_DELETE.equals(face)) { //发送删除事件 if (index > 0) { editText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } } else { face = "{:" + face + ":}"; int size = SizeUtils.dp2px(20); Drawable drawable = getResources().getDrawable(faceId); drawable.setBounds(0, 0, size, size); ImageSpan imageSpan = new ImageSpan(drawable, ALIGN_BOTTOM); SpannableString spannableString = new SpannableString(face); spannableString.setSpan(imageSpan, 0, face.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (index < 0 || index >= editText.getText().length()) { editText.getEditableText().append(spannableString); } else { editText.getEditableText().insert(index, spannableString); } editText.setSelection(index + face.length()); } } }
Example 3
Source File: InputHelper.java From KJFrameForAndroid with Apache License 2.0 | 5 votes |
public static void backspace(EditText editText) { if (editText == null) { return; } KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 4
Source File: Utils.java From Emoji with Apache License 2.0 | 4 votes |
static void backspace(@NonNull final EditText editText) { final KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 5
Source File: EmojiconsFragment.java From talk-android with MIT License | 4 votes |
public static void backspace(EditText editText) { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 6
Source File: ExpressionTransformEngine.java From android-expression with Apache License 2.0 | 4 votes |
public static void delete(EditText editText) { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 7
Source File: TimePickerTextInputKeyControllerTest.java From material-components-android with Apache License 2.0 | 4 votes |
private static void pressKeys(EditText editText, int... keycodes) { for (int key : keycodes) { editText.dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, key, 0)); editText.dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_UP, key, 0)); } }
Example 8
Source File: EmojiconsFragment.java From EmojiChat with Apache License 2.0 | 4 votes |
public static void backspace(EditText editText) { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 9
Source File: EmojiconsFragment.java From EmojiEverywhere with GNU General Public License v2.0 | 4 votes |
public static void backspace(EditText editText) { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }
Example 10
Source File: EmojiconsFragment.java From emojicon with Apache License 2.0 | 4 votes |
public static void backspace(EditText editText) { KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); editText.dispatchKeyEvent(event); }