@Retention(value=CLASS) @Target(value=METHOD) public @interface KeyLongPress
This annotation is intended to be used on methods to receive long press event
on a key. This annotation can be used on methods of classes which implements
KeyEvent.Callback.
The annotation value should be one or several of
KeyEvent constant fields which name contains KEYCODE. If
not set, the method name will be used as the KeyEvent
.KEYCODE_* field name.
The method may return a boolean, void, or a
Boolean. If returning void, it will be considered as
returning true (ie: the method has handled the event).
The method MAY have one parameter:
KeyEvent parameter to know which key has been down
Example :
@EActivity
public class MyActivity extends Activity {
@KeyLongPress
void enter() {
// ...
}
@KeyLongPress
void onEnter() {
// ...
}
@KeyLongPress
void onEnterPressed() {
// ...
}
@KeyLongPress
void enterPressed() {
// ...
}
@KeyLongPress(KeyEvent.KEYCODE_0)
void keyZeroIsLongPressed(KeyEvent keyEvent) {
// ...
}
@KeyLongPress({ KeyEvent.KEYCODE_M, KeyEvent.KEYCODE_N })
boolean multipleKeys(KeyEvent keyEvent) {
return false;
}
}
KeyEvent,
KeyEvent.Callback,
KeyEvent.Callback.onKeyLongPress(int, android.view.KeyEvent)| Modifier and Type | Optional Element and Description |
|---|---|
int[] |
value
The
KeyEvent class constants which name contains
KEYCODE. |
Copyright © 2010–2016 simpligility technologies inc.. All rights reserved.