I have a list view and I am listening using Key listener for KEYCODE_5. The issue I am facing is whenever I press 5, the function onKey() (inside the listener) is called twice. Any idea?
+1
A:
Could it be that you are not checking wether the the event was fired for keyup or keydown?
If you only need to catch the event for keydown you could create your eventhandler like this:
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "5" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_5)) {
// Perform action on key press
// Your event code goes here
return true;
}
return false;
}
Falle1234
2010-10-07 05:35:35
that was the error...thanks a lot...
mdv
2010-10-07 08:59:23