打开软键盘
/**
? ? ?* 打開軟鍵盤
? ? ?*
? ? ?*/
? ? public static void openKeybord(Activity mActivity,EditText mEditText) {
? ? ? ? if (mActivity != null){
? ? ? ? ? ? mEditText.requestFocus();
? ? ? ? ? ? InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? ? ? imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
? ? ? ? }
? ? }
? ? /**
? ? ?* 關閉軟鍵盤
? ? ?*/
? ? public static void closeKeybord(Activity mActivity, EditText mEditText) {
? ? ? ? if (mActivity != null){
? ? ? ? ? ? InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? ? ? if(imm.isActive() && mActivity.getCurrentFocus()!=null){
? ? ? ? ? ? ? ? if (mActivity.getCurrentFocus().getWindowToken()!=null) {
? ? ? ? ? ? ? ? ? ? imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? public static void hide(EditText editText) {
? ? ? ? editText.clearFocus();
? ? ? ? InputMethodManager imm = (InputMethodManager) BaseApplication.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
? ? }
? ? //此方法只是關閉軟鍵盤
? ? public static void hide(Activity mActivity) {
? ? ? ? InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? if (imm.isActive() && mActivity.getCurrentFocus() != null) {
? ? ? ? ? ? if (mActivity.getCurrentFocus().getWindowToken() != null) {
? ? ? ? ? ? ? ? imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? ?* 打開軟鍵盤
? ? ?*
? ? ?*/
? ? public static void openKeybord(Activity mActivity,EditText mEditText) {
? ? ? ? if (mActivity != null){
? ? ? ? ? ? mEditText.requestFocus();
? ? ? ? ? ? InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? ? ? imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
? ? ? ? }
? ? }
? ? /**
? ? ?* 關閉軟鍵盤
? ? ?*/
? ? public static void closeKeybord(Activity mActivity, EditText mEditText) {
? ? ? ? if (mActivity != null){
? ? ? ? ? ? InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? ? ? if(imm.isActive() && mActivity.getCurrentFocus()!=null){
? ? ? ? ? ? ? ? if (mActivity.getCurrentFocus().getWindowToken()!=null) {
? ? ? ? ? ? ? ? ? ? imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? public static void hide(EditText editText) {
? ? ? ? editText.clearFocus();
? ? ? ? InputMethodManager imm = (InputMethodManager) BaseApplication.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
? ? }
? ? //此方法只是關閉軟鍵盤
? ? public static void hide(Activity mActivity) {
? ? ? ? InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
? ? ? ? if (imm.isActive() && mActivity.getCurrentFocus() != null) {
? ? ? ? ? ? if (mActivity.getCurrentFocus().getWindowToken() != null) {
? ? ? ? ? ? ? ? imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
? ? ? ? ? ? }
? ? ? ? }
? ? }
總結
- 上一篇: 维朗门窗怎么样 详解维朗门窗的品质与服务
- 下一篇: 如何正确清洁各种材质的墙面?