How to mimic Google Keyboard's spacebar long-p

2020-05-07 07:56发布

问题:

Google Keyboard lets you long-press the spacebar to switch keyboards in Android. I haven't turned anything up with a Google search but I'm certain there's a way to do this programmatically.

How can I bring up the input method picker?

回答1:

They use showInputMethodPicker():

private void onSpaceBarLongPress() {
    InputMethodManager imm = (InputMethodManager)
        getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showInputMethodPicker();
}