我使用的是custom in-app keyboard,所以我需要禁用系统键盘。我可以用如何使用setTextIsSelectable禁用键盘后启用键盘
editText.setShowSoftInputOnFocus(false);
对于Android API 21+。但要做到同样的事情到API 11,我做
editText.setTextIsSelectable(true);
有时候我想与setTextIsSelectable
禁用后再次显示系统键盘。但我无法弄清楚如何。执行以下操作将显示系统键盘,但如果用户隐藏键盘,然后再次单击EditText,则键盘仍不会显示。
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, 0);
我想我能做到editText.setOnFocusChangeListener
,然后手动显示或隐藏系统键盘,但我宁愿取消任何setTextIsSelectable
一样。以下也不起作用:
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.setClickable(true);
editText.setLongClickable(true);
我该怎么办?