Eidtext这个控件默认是你点击了它获得焦点之后就会自动地弹出软键盘,前提是你在竖屏的时候。但横盘的时候,不会自动弹出弹
出软键盘了。
隐藏软件盘
法一. InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);//开始时隐藏输入法
法二:AndroidManifet.xml中对Activity进行设置。如:android:windowSoftInputMode="stateUnchanged|adju//stPan"
手动弹出软键盘
- InputMethodManager im = ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE));
- im.showSoftInput(tv, 0);
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- InputMethodManager im = ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE));
- if (im.showSoftInput(tv, InputMethodManager.SHOW_FORCED)) {
- System.out.println(" return is true fullscreenmode"
- + im.isFullscreenMode());
- } else {
- System.out.println(" return is not true");
- }
- };
在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"