Eidtext这个控件默认是你点击了它获得焦点之后就会自动地弹出软键盘,前提是你在竖屏的时候。但横盘的时候,不会自动弹出弹
出软键盘了。
隐藏软件盘
法一. InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);//开始时隐藏输入法
法二:AndroidManifet.xml中对Activity进行设置。如:android:windowSoftInputMode="stateUnchanged|adju//stPan"
手动弹出软键盘
在AlertDialog中点击输入框可显示输入法,但是要选中输入法还得添加:
alertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
官方:http://developer.android.com/reference/android/app/Dialog.html
Often you will want to have a Dialog display on top of the current input method, because there is no reason for it to accept text. You can do this by setting the WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
window flag (assuming your Dialog takes input focus, as it the default) with the following code:
android:windowSoftInputMode="adjustPan|stateHidden"