问题
how to get a field press event in blackberry。
I write a component extends Field class , want to get a press event( press down still not press up ) .
please help me.
回答1:
You can override this method:
protected boolean keyDown(int keycode, int time)
About the key up presses, there's a keyUp
which is the method you should override to perform an action when the key is released instead of pressed (you can press and hold, and the action doesn't normally get fired until released). However, the OS doesn't callback on key up events unless it is explicitly told to do so by your app, for performance reasons.
回答2:
You can overide keydown method of any field variable , or you can override navigationClick method of click
public ButtonField btn = new ButtonField("Hello");
protected boolean navigationClick(int status, int time)
{
Field f1 = getFieldWithFocus().getLeafFieldwithFocus()
if(f1 == btn)
{
<Perform your business logics>
}
Thanks
来源:https://stackoverflow.com/questions/11759289/how-to-get-a-field-press-event-in-blackberry