安卓软键盘的自动弹起/隐藏

Toggle软键盘:

InputMethodManager imm = (InputMethodManager) getActivity()
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

 

 隐藏软键盘: 

InputMethodManager im = (InputMethodManager) v.getContext()
						.getSystemService( Context.INPUT_METHOD_SERVICE );  
				if (im.isActive()){  
				    im.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);  
				}

 

 

 

Manifest下设置:

//一个例子,适用于切入页面即触发EditText
<activity 
            android:name="com.uustudio.unote.activity.NoteEditActivity"
            android:label="@string/app_name" 
            android:configChanges="orientation|keyboardHidden|locale" 
            android:screenOrientation="portrait" 
            android:windowSoftInputMode="stateVisible|adjustPan" >

 

posted @ 2015-09-23 22:09  misybing  阅读(347)  评论(0编辑  收藏  举报