简体   繁体   中英

Show soft keyboard with no input

I'm implemented an Activity where the control is the soft keyboard (I'd like to perfom some actions when some keys are pressed)

so I'd like to show the keyboard (having no an EditText or similar) and read the touches with

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    return super.onKeyDown(keyCode, event);

}

The keyboard should be always visible within the app. Is that possible? How can I do it? Thanks

Can't test if it works at the moment, but I know there's both a show/hide soft keyboard for EditTexts at the very least, but maybe it will work with any View:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInputFromWindow(viewToAnchorTo.getWindowToken(), 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM