Activity啓動edittext自動彈出軟鍵盤解決辦法
1)在Manifest.xml文件中相應的activity下添加一下代碼:
android:windowSoftInputMode="stateHidden"
2)EditText始終不彈出軟鍵盤
EditText edit=(EditText)findViewById(R.id.edit);
edit.setInputType(InputType.TYPE_NULL);
3)在onCreate方法中加入以下代碼使不彈出軟件鍵盤
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
4)
InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(homepageLayout.getWindowToken(), 0);
——homepageLayout爲當前視圖
5)
//去虛擬輸入欄
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);