2
このケースでは、ソフトキーボードがオンであることを確認して、コードを閉じることができません。次のコードを使用すると、コードがフォーカスを見つけることができないため、キーボードは閉じられませんが、キーボードはオンですだから私はそれをどのように隠すことができますか?Androidでフォーカスのないソフトキーボードを隠すには?
private void hideSoftKeyboard() {
Activity activity = (Activity) sContext;
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
//((Activity) sContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
} else {
Log.i(sClassTag,"focus not found");
}
}
'ビュービューを見つけることができます= this.getCurrentFocus(); if(view!= null){ InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken()、0); } ' –
' InputMethodManager imm =(InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY、0); ' –
[Androidソフトキーボードを閉じる/隠す]の複製があります(http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard)。 ) –