n~droid generation

Taking ndroid for a ride…

Show soft keyboard with EditText on android

| Filed under howtos

So you wish to show or hide the virtual (soft) keyboard in your Android app.

While you are executing n action that places focus into the EditText field you wish for the keyboard to pop up.
You need to tell android (or the emulator) to bring up a the soft keyboard.
 
Note:
EditTexts are focusable while the system is in ‘touch mode’.
The first click event focuses the control, while the second click event actually fires the OnClickListener.
If you disable touch-mode focus with:
(xml) View attribute
OR
(java)
 
Then OnClickListener should fire as expected.


To launch the keyboard requires the following additional code:
 
xml:
——

 

Notice the imeOptions: actionSend|flagNoEnterAction:

The tell you android to apply the SEND button action to the EditText and not to accept ENTER on soft keyboard.
 
Java:
——-
FIRST POSSIBILTY USING THE setOnClickListener:

 
 
SECOND POSSIBILTY USING THE setOnFocusChangeListener:
 

You do not need to use both…
they can be implemented for other use.

Jud Luck…

Development & Design: http://nwg.co.il
  • Google+
  • LinkedIn