当设备处于横向模式时显示软键盘

and*_*eea 8 java android landscape android-softkeyboard

此代码似乎不适用于横向模式:

EditText destinationSearch = (EditText) findViewById(R.id.destinationSearch); 
Run Code Online (Sandbox Code Playgroud)

destinationSearch.requestFocus(); InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(destinationSearch,InputMethodManager.SHOW_IMPLICIT);

有没有解决方案在横向模式下显示软键盘?

Bak*_*kih 11

你需要使用show forced

InputMethodManager imm;
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);
imm.showSoftInput(this.editText,InputMethodManager.SHOW_FORCED);
Run Code Online (Sandbox Code Playgroud)