如何在黑莓中为editField设置onKeyEnter事件?
如何为EditField
设置onKeyEnter
事件。我当前的屏幕中有两个 EditField
。但我必须只设置一个 EditField
事件。我该如何设置呢?我在同一屏幕中有按钮字段和列表字段。我什至可以为按钮和列表设置点击。但问题是为 EditField
设置事件。
我已经使用了 key down 和 keychar 方法。但这对我没用。 我用下面的方法检查了。
protected boolean keyChar(char key, int status, int time){
if (key == Characters.ENTER){Dialog.alert("hi");}
return false;
}
protected boolean keyChar(char character, int status, int time){
if (Characters.ENTER == character){Dialog.alert("hi");}
return false;
}
如果我这样使用,我无法在编辑字段中输入任何字符。
谁能帮助我吗?
How to set onKeyEnter
event for EditField
. I have two EditField
in my current screen. But i have to set event only one EditField
.How can I set that?. I have Button field and list field in the same screen. I can able to set click even for both button and list.But problem is setting event for EditField
.
I have used both key down and keychar method. But that not use to me.
I checked with following method.
protected boolean keyChar(char key, int status, int time){
if (key == Characters.ENTER){Dialog.alert("hi");}
return false;
}
protected boolean keyChar(char character, int status, int time){
if (Characters.ENTER == character){Dialog.alert("hi");}
return false;
}
If i am using like this I can't enter any character in both my editfield.
Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你正在吃掉所有的击键,因为你没有返回 super.keyChar(key, status, time)。
如果您不消耗密钥,则需要将其向上传递。
You're eating all the keystrokes because you're not returning super.keyChar(key, status, time).
If you don't consume the key, you need to pass it on up.