Reputation: 87
My application has started to behave strangely, so I think there must have been a change that I am not grasping. I have an EditText in a RelativeLayout with a requestFocus attribute. For months I would open my app and execute an initialize method and then touch the edit text and the keyboard would appear. Now the keyboard does not appear. I have tried to set an onClick Listener and onFocusChange with the InputMethodManager using:
m.showSoftInput(amountEditText, 0);
and also with
m.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
Since this is new, unexpected behavior, I am afraid that there was something I changed that caused this odd behavior. I have looked at the XML and the WYSIWYG for the view and cannot see anything wrong. The SO answers all seem to have much more complex situations that this so I think something more basic is at fault. Anyone seen this before?
Upvotes: 0
Views: 104
Reputation: 126
Sometime ago I was facing a similar problem. One way to force the keyboard to be shown is this way:
//here my EditText is called editText_search
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(editText_search.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
editText_search.requestFocus();
Also, as Simon Marquis pointed out, see if you're blocking or hiding the keyboard in your Manifest.
Hope it helps.
Upvotes: 1
Reputation: 7526
Try this method:
public static void showSoftkeyboard(android.view.View view, ResultReceiver resultReceiver) {
Configuration config = view.getContext().getResources().getConfiguration();
if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (resultReceiver != null) {
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT, resultReceiver);
} else {
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
}
}
Also, check your AndroidManifest.xml if you didn't disable the softKeyboard for your Activity.
Upvotes: 1