android 软键盘自动弹出和关闭

 一、布局中软键盘自动弹出

 bargain_dialog_offer_edit.requestFocus();

 bargain_dialog_offer_edit.setFocusable(true);

 InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

 imm.showSoftInputFromInputMethod(bargain_dialog_offer_edit.getWindowToken(),0);             

 

二、布局中软键盘自动关闭 

InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);  imm.hideSoftInputFromWindow(talking_edit.getWindowToken() , 0); 

 

三、对话框中软键盘自动弹出和关闭

 

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

posted @ 2015-04-30 18:01  骨头森林  阅读(469)  评论(0编辑  收藏  举报