标签:
1 如果Activity页面有EditText,为了不影响用户体验,我们需要在进入该页面时不弹出软键盘。如何设置呢?
在mainifest.xml文件中配置Activity时,设置这两句即可:
android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="adjustUnspecified|stateHidden"
//隐藏输入法 public void closeSoftKeboard(EditText edit){ InputMethodManager inputMethodManager = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(edit.getWindowToken() ,0); }
edit.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if(s.toString().length()==11){ closeSoftKeboard(edit); } } });
标签:
原文地址:http://blog.csdn.net/u010152805/article/details/43021101