I am able to open and close the soft keyboard on Android and accept text input to a TextView. All works fine. The problem is, I don't want to actually see the text input field above the keyboard that takes up the entire screen. I've set the TextView's input type to InputType.TYPE_NULL, which hides the text field and only shows the keyboard, but when I do this it does not accept input from the keyboard:
//doesn't show text field above soft
//keyboard, but also doesn't take input
tview.setInputType(InputType.TYPE_NULL);
I can't seem to figure out how to disable the text field. I only want the keyboard because I need to show things in the UI while the user is typing without the text input box covering the entire screen.
UPDATE: Turns out I could just send the key input from the soft keyboard directly to a non-TextView. In other words, it is possible to get soft keyboard input to any subclass of View, and it does not specifically need to deal with text or text editing. This answer explains it: https://stackoverflow.com/a/7386854/420163
I modified the onCreateInputConnection (which is part of the View class) to do this:
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
//Log.d(TAG, "onCreateInputConnection");
BaseInputConnection b = new BaseInputConnection(this, false);
outAttrs.actionLabel = null;
outAttrs.inputType = InputType.TYPE_NULL;
outAttrs.imeOptions = EditorInfo.IME_FLAG_FORCE_ASCII|EditorInfo.IME_FLAG_NO_FULLSCREEN|EditorInfo.IME_FLAG_NO_EXTRACT_UI;
return b;
}
The EditorInfo.IME_FLAG_NO_FULLSCREEN|EditorInfo.IME_FLAG_NO_EXTRACT_UI flags hid the text edit box that shows with the soft keyboard and kept it from covering the screen. The main view now receives key events from the soft keyboard using public boolean onKey(View v, int keyCode, KeyEvent event).