弹出与关闭然键盘

public class KeyboardUtils {

//传进来的view要是EditText

public static void openSoftInput(View view, Context context) {
((InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(
view, InputMethodManager.RESULT_SHOWN);
}


public static void closeSoftInput(View view, Context context) {
((InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

}


调用:

public void OpenKeyboard(View view) {
KeyboardUtils.openSoftInput(eText, this);
}


public void CloseKeyboard(View view) {
KeyboardUtils.closeSoftInput(eText, this);
}

你可能感兴趣的:(软键盘)