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);

你可能感兴趣的:(android)