[英]Android softkeyboard not triggerring
我的屏幕上有多個EditText,其中之一被聚焦。 屏幕彈出后,軟鍵盤不會立即觸發。 我希望軟鍵盤在屏幕彈出時立即觸發。 如果我不實現onFocusChangeListener(),它將很好地工作。 但是我需要onFocusChangeListener()來檢測哪個editText被聚焦。 我嘗試設置setFocusable(true)和setFocusableInTouchMode(true)。 我也不想修改AndroidMenifest.xml中的android:windowSoftInputMode屬性。 我有以下標准:
這是我的代碼片段
final InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mInput.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
mIsFocused = hasFocus;
if(hasFocus)
inputMethodManager.showSoftInput(mInput, InputMethodManager.SHOW_IMPLICIT);
}
});
有什么建議么 ?
您可以通過編程方式打開軟鍵盤
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
您可以嘗試使用inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)
。
來源: Stackoverflow發布
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.