PHP
·
发表于 5年以前
·
阅读量:8391
@TargetApi (Build.VERSION_CODES.CUPCAKE)
public static void hideSoftInput(Activity activity) {
View view = activity.getWindow().peekDecorView();
if (view != null ) {
InputMethodManager inputmanger = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0 );
}
}
@TargetApi (Build.VERSION_CODES.CUPCAKE)
public static void hideSoftInput(Context context, EditText edit) {
edit.clearFocus();
InputMethodManager inputmanger = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0 );
}