Android的对话框显示与隐藏

来源:互联网 发布:软件光盘品牌 编辑:程序博客网 时间:2024/05/18 02:50

对话框切换显示

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 

焦点监听软键盘

@Override    public void onFocusChange(View v, boolean hasFocus) {        InputMethodManager imm = (InputMethodManager)getContext()        .getSystemService(Context.INPUT_METHOD_SERVICE);        if (hasFocus)        {            imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);        }        else        {            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);        }    }

系统控制软键盘隐藏

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(MainActivity.this.getCurrentFocus().getWindowToken(), 0);
0 0