Reputation: 1687
I code to ban system soft keyboard.It can achieve the effct,but it disappear after one flash.I don't want this one flash.This is my code.
public class MainActivity extends Activity {
private EditText mEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mEditText = (EditText) findViewById(R.id.test_et);
mEditText.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
hideSoftInputMode((EditText)v);
}
});
}
private void hideSoftInputMode(EditText editText) {
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(editText.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
Upvotes: 0
Views: 194
Reputation: 6712
There is another way - don't lay focus on your EditText. Set it on the View at the background (the Layout) or something. This can be done by using:
setFocusable(true);
requestFocus();
This should do the trick for you without working with the Manifest etc.
Upvotes: 1
Reputation: 31846
In your manifest file, you can set the windowSoftInputMode
to stateAlwaysHidden
:
<activity
...other attributes
android:windowSoftInputMode="stateAlwaysHidden">
</activity>
Upvotes: 3