android不定参数和代码隐藏软键盘

import android.view.inputmethod.InputMethodManager;
public static boolean closeInputKeyboard(Context context,EditText... editTexts) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
for (EditText editText : editTexts) {
if (editText.hasFocus()) {
return imm.hideSoftInputFromWindow(editText.getApplicationWindowToken(),0);
}
}
}
return false;

}

其中调用的时候

closeInputKeyboard(this, ed1, ed2,ed3);// ed1,ed2,ed3是EditText类型变量

猜你喜欢

转载自blog.csdn.net/ahaitongxue/article/details/80525694
今日推荐