OnKeyboardActionListener的Andr​​oid按键 [英] OnKeyboardActionListener android keys

查看:1265
本文介绍了OnKeyboardActionListener的Andr​​oid按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现的方式来知道什么时候有一个preSS和软键盘上的一个键的释放。我已经使用了onKeyListener获取向下和密钥的,但与该问题是,它只能硬键盘上。我发现里面好像有此功能的OnKeyBoardActionListener。我遇到的问题,这是我需要从我使用了简单的测试一个EditText的KeyboardView。

I'm trying to implement a way to know when there is a press and a release of a key on a soft keyboard. I have used the onKeyListener to get the down and the up of the key, but the problem with that is that it only works on a hard keyboard. I have found the OnKeyBoardActionListener which seems to have this functionality. The problem I am running into with this is that i need to get the KeyboardView from an edittext i am using for simple testing.

public class testing extends Activity implements KeyboardView.OnKeyboardActionListener{
     EditText testingBox;
     TextView textbox;
     KeyboardView keyView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    textbox = (TextView)findViewById(R.id.TextView01);


    testingBox = (EditText)findViewById(R.id.EditText01);

    //keyView is null i need to get it somehow.  

    keyView.setOnKeyboardActionListener(this);
}
//methods for the OnKeyBoardActionListener
}

如果任何人都可以提供关于如何我能得到这个keyBoardView或另一种方式,我可以捕捉这些软键盘presses和释放将是巨大的任何意见。谢谢。

if anyone could provide any advice on how i can get this keyBoardView or another way i can capture these soft keyboard presses and releases would be great. thanks.

推荐答案

我相信捕捉softkeyboard的确切preSS和释放的唯一途径是从IME内。你可以看到文本通过 TextWatcher 。

I believe the only way to capture the exact press and releases of a softkeyboard is from within the IME. You can see the text changing via a TextWatcher.

我觉得这部分是因为一个输入法可能没有钥匙向下和向上的机制。一个IME不一定需要看起来像一个标准的QWERTY键盘。这可能是这样的Swype,在那里你绘制图案和文字出来。

I think this is partially because an IME may not have key down and up mechanisms. An IME does not necessarily need to look like a standard qwerty keyboard. It might be something like Swype, where you draw a pattern and words come out.

这篇关于OnKeyboardActionListener的Andr​​oid按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆