本文整理匯總了Java中android.view.KeyEvent.dispatch方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.dispatch方法的具體用法?Java KeyEvent.dispatch怎麽用?Java KeyEvent.dispatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.dispatch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: emulateShiftHeld
import android.view.KeyEvent; //導入方法依賴的package包/類
public void emulateShiftHeld() {
try {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(this, null, null);
Toast.makeText(getContext() , R.string.select_text_now, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Timber.e(e, "Exception in emulateShiftHeld()");
}
}
示例2: dispatchKeyEvent
import android.view.KeyEvent; //導入方法依賴的package包/類
/**
* Called to process key events. You can override this to intercept all
* key events before they are dispatched to the window. Be sure to call
* this implementation for key events that should be handled normally.
*
* @param event The key event.
*
* @return boolean Return true if this event was consumed.
*/
public boolean dispatchKeyEvent(KeyEvent event) {
onUserInteraction();
// Let action bars open menus in response to the menu key prioritized over
// the window handling it
final int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_MENU &&
mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
return true;
} else if (event.isCtrlPressed() &&
event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
// Capture the Control-< and send focus to the ActionBar
final int action = event.getAction();
if (action == KeyEvent.ACTION_DOWN) {
final ActionBar actionBar = getActionBar();
if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
mEatKeyUpEvent = true;
return true;
}
} else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
mEatKeyUpEvent = false;
return true;
}
}
Window win = getWindow();
if (win.superDispatchKeyEvent(event)) {
return true;
}
View decor = mDecor;
if (decor == null) decor = win.getDecorView();
return event.dispatch(this, decor != null
? decor.getKeyDispatcherState() : null, this);
}
示例3: dispatchKeyEvent
import android.view.KeyEvent; //導入方法依賴的package包/類
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
final View decor = mActivity.getWindow().getDecorView();
return event.dispatch(mActivity, decor != null ? decor.getKeyDispatcherState() : null, mActivity);
}
示例4: dispatch
import android.view.KeyEvent; //導入方法依賴的package包/類
public boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
return event.dispatch(receiver);
}
示例5: dispatch
import android.view.KeyEvent; //導入方法依賴的package包/類
public static boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
return event.dispatch(receiver, (DispatcherState) state, target);
}