static void hideSoftInputFromWindow(Instrumentation inst, View view) {
InputMethodManager imm = (InputMethodManager) inst.getTargetContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} 我用上面的方法隐藏可以成功隐藏android 的默认的输入法,但是我下载了其他的 输入法后会先打开,然后隐藏,闪一下怎么办输入法Android隐藏InputMethodManager
InputMethodManager imm = (InputMethodManager) inst.getTargetContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} 我用上面的方法隐藏可以成功隐藏android 的默认的输入法,但是我下载了其他的 输入法后会先打开,然后隐藏,闪一下怎么办输入法Android隐藏InputMethodManager
Context().INPUT_METHOD_SERVICE);
boolean isOpen=imm.isActive();
if(!isOpen)
{
imm.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus()
.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
}
WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
if(params.softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED || params.softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE){
View view = getActivity().getCurrentFocus();
InputMethodManager imm = null ;
if(mContext == null){
imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
}else{
imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
如果针对某个Activity 不让其显示键盘的话 可以在ManiFest.xml 相应Actvity标签 增加
android:windowSoftInputMode="adjustNothing|stateAlwaysHidden"属性