开发者

How to use OnKeyboardActionListener?

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

I want to call my method, whenever user type any character on keyboard. OnKeyListener 开发者_Python百科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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜