if (direction != 0) {
View focused = mView != null ? mView.findFocus() : null;
if (focused != null) {
View v = focused.focusSearch(direction);
if (v != null && v != focused) {
// do the math the get the interesting rect
// of previous focused into the coord system of
// newly focused view
focused.getFocusedRect(mTempRect);
if (mView instanceof ViewGroup) {
((ViewGroup) mView).offsetDescendantRectToMyCoords(
focused, mTempRect);
((ViewGroup) mView).offsetRectIntoDescendantCoords(
v, mTempRect);
}
if (v.requestFocus(direction, mTempRect)) {
playSoundEffect(
SoundEffectConstants.getContantForFocusDirection(direction));
finishKeyEvent(event, sendDone, true);
return;
}
}
// Give the focused view a last chance to handle the dpad key.
if (mView.dispatchUnhandledMove(focused, direction)) {
finishKeyEvent(event, sendDone, true);
return;
}
}
}
本文介绍了一种在用户界面中实现焦点导航的方法。当方向不为零时,查找当前聚焦视图,并尝试将焦点转移到指定方向上的下一个可聚焦视图。如果找到合适的视图,则更新焦点并播放反馈声音效果。
1956

被折叠的 条评论
为什么被折叠?



