日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java hasfocus_Java KeyEvent.hasNoModifiers方法代碼示例

發布時間:2024/9/19 71 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java hasfocus_Java KeyEvent.hasNoModifiers方法代碼示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import android.view.KeyEvent; //導入方法依賴的package包/類

@Override

public boolean onKeyDown(int keyCode, KeyEvent event) {

// We need to handle focus change within the SimpleMonthView because we are simulating

// multiple Views. The arrow keys will move between days until there is no space (no

// day to the left, top, right, or bottom). Focus forward and back jumps out of the

// SimpleMonthView, skipping over other SimpleMonthViews in the parent ViewPager

// to the next focusable View in the hierarchy.

boolean focusChanged = false;

switch (event.getKeyCode()) {

case KeyEvent.KEYCODE_DPAD_LEFT:

if (event.hasNoModifiers()) {

focusChanged = moveOneDay(isLayoutRtl());

}

break;

case KeyEvent.KEYCODE_DPAD_RIGHT:

if (event.hasNoModifiers()) {

focusChanged = moveOneDay(!isLayoutRtl());

}

break;

case KeyEvent.KEYCODE_DPAD_UP:

if (event.hasNoModifiers()) {

ensureFocusedDay();

if (mHighlightedDay > 7) {

mHighlightedDay -= 7;

focusChanged = true;

}

}

break;

case KeyEvent.KEYCODE_DPAD_DOWN:

if (event.hasNoModifiers()) {

ensureFocusedDay();

if (mHighlightedDay <= mDaysInMonth - 7) {

mHighlightedDay += 7;

focusChanged = true;

}

}

break;

case KeyEvent.KEYCODE_DPAD_CENTER:

case KeyEvent.KEYCODE_ENTER:

if (mHighlightedDay != -1) {

onDayClicked(mHighlightedDay);

return true;

}

break;

case KeyEvent.KEYCODE_TAB: {

int focusChangeDirection = 0;

if (event.hasNoModifiers()) {

focusChangeDirection = View.FOCUS_FORWARD;

} else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {

focusChangeDirection = View.FOCUS_BACKWARD;

}

if (focusChangeDirection != 0) {

final ViewParent parent = getParent();

// move out of the ViewPager next/previous

View nextFocus = this;

do {

nextFocus = nextFocus.focusSearch(focusChangeDirection);

} while (nextFocus != null && nextFocus != this &&

nextFocus.getParent() == parent);

if (nextFocus != null) {

nextFocus.requestFocus();

return true;

}

}

break;

}

}

if (focusChanged) {

invalidate();

return true;

} else {

return super.onKeyDown(keyCode, event);

}

}

總結

以上是生活随笔為你收集整理的java hasfocus_Java KeyEvent.hasNoModifiers方法代碼示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。