android 常用控件总结
DisplayToast("按下:右方向键");
break;
}
return super.onKeyDown(keyCode, event);
}
/* 按键弹起所触发的事件*/
public boolean onKeyUp(int keyCode, KeyEvent event){
switch (keyCode){
case KeyEvent.KEYCODE_DPAD_CENTER:
DisplayToast("弹起:中键");
break;
case KeyEvent.KEYCODE_DPAD_UP:
DisplayToast("弹起:上方向键");
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
DisplayToast("弹起:下方向键");
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
DisplayToast("弹起:左方向键");
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
DisplayToast("弹起:右方向键");
break;
}
return super.onKeyUp(keyCode, event);
}
//用于响应按键重复点击,官方API指出onKeyMultiple方法总是返回false,即它没有handle,因此必须重写才能实现-------------------此方法没用过具体情况怎么样不是很清楚?
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event){
return super.onKeyMultiple(keyCode, repeatCount, event);
}