Answer the question
In order to leave comments, you need to log in
Handling keypresses in custom view?
I want to make a semblance of a wireless keyboard, and for this I need to process keyboard input.
It is important for me that there is no input text, no selection, copying, and other things typical for EditText, just a keyboard, preferably full screen.
developer.android.com/training/keyboard-input/inde... , the official source and googling did not give much, and now, in desperation, I am writing questions here.
1. How to call the soft keyboard programmatically (methods from the documentation do not work)?
2. How to handle keystrokes (considering different languages)?
3. Is it possible to stretch the keyboard to full screen?
Answer the question
In order to leave comments, you need to log in
The method of scientific poke helps out. The keyboard can be invoked on the TextView and its children in this way
public void showSoftKeyboard(View view) {
if (view.requestFocus()) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
}
EditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // в альбомном виде не показывается поле ввода и прочее
EditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); // не показываются подсказки
1. Now I'm doing a project, the keyboard is called with a bang.
private void showKeyboard() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
или
private void showKeyboard(EditText editText) {
InputMethodManager imm = (InputMethodManager) AddPeriodActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question