How to hide soft keyboard for one of the EditText when soft keyboard is already shown?
Here the situation: I am showing a screen with 4 input fields, 2 of them need to be edit by user (numeric field), other (text field)- shows some text info which can be changed by user via ListView, but it closed for manual edit.
I use in my XML file android:editable="false"
for non-numeric EditText fields and it helps to disable popup of soft keyboard when the user click on field. But the problem is in when the user edit a numeric field the soft keyboard not hidding aft开发者_运维问答er user focused on text field.
So how can I hide the already shown soft keyboard when user focused on my text field?
The methods like:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(MEdit1.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
or something like this
MetricEdit = (EditText) findViewById(R.id.MetricEdit);
MetricEdit.setInputType(0);
take no effect.
Thanks in advance for your time.
try putting
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(MEdit1.getWindowToken(), 0);
in the onclicklistener for the edittext that is editable
you can also change the numeric edittext's keyboard to have a "done" at the bottom with the following:
android:imeOptions="actionDone"
in the xml for the edittext
This will help..
edittext.setInputType(InputType.TYPE_NULL);
if (android.os.Build.VERSION.SDK_INT >= 11)
{
edittext.setRawInputType(InputType.TYPE_CLASS_TEXT);
edittext.setTextIsSelectable(true);
}
精彩评论