我在網上用了很多方法都沒有成功,但是不能彈出軟件不過我找到了兩個方法是可以實現的.
第一種方法:
//只用下面這一行彈出對話框時需要點擊輸入框才能彈出軟鍵盤
alert_leaveMsg.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
//加上下面這一行彈出對話框時軟鍵盤隨之彈出??
alert_leaveMsg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
方法二:
/**
* EditText獲取焦點并顯示軟鍵盤
*/
public? void showSoftInputFromWindow( EditText editText) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
//getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
//調用系統輸入法
InputMethodManager inputManager = (InputMethodManager) editText
.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
第三種方法:
是在style中設置dialog樣式