Handling "Key Press" from Soft Keyboard in EditText

1562 views
Skip to first unread message

Gaurav Vaish

unread,
Mar 29, 2010, 6:11:26 AM3/29/10
to Android Developers
Hi,

I'm trying to handle the key-press event (OnKeyListener). I know that
doesn't work
http://groups.google.com/group/android-developers/browse_thread/thread/43c2140c0d687899

I tried to set a custom KeyListner (not OnKeyListener) using:

1. public void setKeyListener -- but the methods onKeyDown/Up/Other
are never called
2. Declaratively using "inputMethod" attribute in XML but it results
in "ClassNotFoundException".

What's the simplest and preferably, most direct and intuitive method,
to handle key-strokes from soft-key in EditText in my applicaiton...
any direction will be useful!

Happy Hacking,
Gaurav
www.mastergaurav.com


Nithin

unread,
Mar 29, 2010, 6:18:27 AM3/29/10
to Android Developers

editText.addTextChangedListener(new TextWatcher()); this interface
contains three methods, which will be called accordingly when you
type using soft keyboard.

Nithin

On Mar 29, 3:11 pm, Gaurav Vaish <gaurav.va...@gmail.com> wrote:
> Hi,
>
> I'm trying to handle the key-press event (OnKeyListener). I know that

> doesn't workhttp://groups.google.com/group/android-developers/browse_thread/threa...

Gaurav Vaish

unread,
Mar 29, 2010, 6:24:47 AM3/29/10
to Android Developers
Hi Nithin,

Thanks for your response however in this case, I won't be notified if
there's no text and "del" key is pressed.

I want notification about "Key"-Down/Up and not just text-part.


--
Happy Hacking,
Gaurav
www.mastergaurav.com

Nithin

unread,
Mar 29, 2010, 8:08:36 AM3/29/10
to Android Developers
use this ,
KeyboardView.OnKeyboardActionListener()

Nithin

Gaurav Vaish

unread,
Mar 29, 2010, 1:14:57 PM3/29/10
to Android Developers
Thanks Nithin, once again.

I did have a look at it but got scared to see that I need to declare
complete "Keyboard" (QWERTY etc) specification.
Otherwise, how do I use the KeyboardView? I could not get a mechanism
to get a reference to the default KeyboardView... :( I must be missing
out something critical


--
Happy Hacking,
Gaurav
www.mastergaurav.com

Reply all
Reply to author
Forward
0 new messages