Android:关闭软键盘自动弹出的解决方案

个人觉得最有效的方法是

在 AndroidMainfest.xml中,为要隐藏软键盘的activity添加属性android:windowSoftInputMode="adjustUnspecified|stateHidden"

<activity
            android:name="com.exmp.app.ui.OrdActivity"
            android:windowSoftInputMode="adjustUnspecified|stateHidden"
            android:screenOrientation="portrait" />

也有其他方法,貌似不管用;

其一、

/**
	 * 隐藏输入法
	 * 
	 * @param view
	 */
	public static void hideInputMethod(View view) {
		InputMethodManager imm = (InputMethodManager) App.getInstance()
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		if (imm.isActive()) imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
	}

其二、

EditText edit=(EditText)findViewById(R.id.edit_text);
  edit.clearFocus();// 失去焦点


发布了63 篇原创文章 · 获赞 67 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/sange77/article/details/47102353