Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing the Soft Keyboard open

Tags:

android

I am trying to force the Soft Keyboard open in an Activity and grab everything that is entered as I want to handle the input myself, I don't have an EditText. Currently I have tried this but it does not work. I would like the Soft Keyboardto open below mAnswerTextView (Note: it is a TextView not EditText).

    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);     // only will trigger it if no physical keyboard is open     mgr.showSoftInput(mAnswerTextView, InputMethodManager.SHOW_IMPLICIT); 
  1. how do I force the Soft Keyboard open
  2. How do I gab everything that is entered so that I can handle each character. I would like to flush each character from the Soft Keyboard after I have handled it. ie, the user should not be able to enter whole words in the Soft Keyboard.
like image 906
jax Avatar asked Mar 19 '10 18:03

jax


People also ask

How do I open a soft keyboard?

By default, the soft keyboard may not appear on the emulator. If you want to test with the soft keyboard, be sure to open up the Android Virtual Device Manager ( Tools => Android => AVD Manager ) and uncheck "Enable Keyboard Input" for your emulator. Now restart the emulator.

How do I turn off soft keyboard on Android?

You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow , passing in the token of the window containing your focused view. This will force the keyboard to be hidden in all situations. In some cases, you will want to pass in InputMethodManager.


1 Answers

try this to force open soft keyboard:

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); 

then you can to use this code to close the keyboard:

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(_pay_box_helper.getWindowToken(), 0); 
like image 165
Dmitry Avatar answered Sep 28 '22 08:09

Dmitry