Addev
Addev

Reputation: 32253

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

Upvotes: 0

Views: 319

Answers (1)

Cruceo
Cruceo

Reputation: 6834

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);

Upvotes: 1

Related Questions