views:

257

answers:

2

Simply say, is there any example about 'OnKeyboardActionListener'?

I want to call my method, whenever user type any character on keyboard. OnKeyListener or OnKeyDown is not called when the word is composing. <- it's a problem. So, I'm trying to use 'OnKeyboardActionListener' to solve the problem above.

A: 

Simply say, is there any example about 'OnKeyboardActionListener'?

This interface is used in the creation of input method editors ("soft keyboards"). The SoftKeyboard sample that shipped with your SDK uses this interface.

I want to call my method, whenever user type any character on keyboard.

If this is your own keyboard, follow the SoftKeyboard example.

CommonsWare
A: 

OnKeyboardActionListener is for implementing software keyboards.

OnKeyListener and OnKeyDown do not get called, as you have discovered, when using a software keyboard. They only get called when using a hardware keyboard, which many Android devices don't even have.

I assume what you are trying to do is capture key events as they are occurring in an EditText area. Your best bet in this case, in order to handle both software keyboard input and hardware keyboard input, is to register a TextWatcher via the addTextChangedListener() method.

Note that on phones with Android 2.1 and later, such as the Nexus One, people have the option of using speech recognition to input text into your EditText instead of typing the text. When they do that you may get full words, or even full sentences, entered all at once. So you need to check the entire contents of the EditText field when there is a change to the contents.

mbaird