gpt4 book ai didi

java - 应用程序中的 Android Wear 手势(版本 1.4),不仅仅用于通知?

转载 作者:太空宇宙 更新时间:2023-11-04 12:55:50 24 4
gpt4 key购买 nike

如何在 Wear 应用中使用 Android Wear 手腕手势?是否有可能检测到它们,例如轻弹手腕滚动?

最佳答案

如果您在 Activity 中注册回调 onKeyDown(),您应该会收到以下通知 events :KEYCODE_NAVIGATE_NEXTKEYCODE_NAVIGATE_PREVIOUSKEYCODE_NAVIGATE_INKEYCODE_NAVIGATE_OUT。这些新手势被映射到这些事件。所以这是一个快速覆盖:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

Log.d(TAG, "onKeyDown Keycode: " + keyCode);

switch (keyCode) {
case KeyEvent.KEYCODE_NAVIGATE_NEXT:
// Do something that advances user view to the next item in an ordered list
return true;
case KeyEvent.KEYCODE_NAVIGATE_PREVIOUS:
// Do something that advances user view to the previous item in an ordered list
return true;
case KeyEvent.KEYCODE_NAVIGATE_IN:
// Do something that activates the item that currently has focus or expands to
// the next level of a navigation hierarchy
return true;
case KeyEvent.KEYCODE_NAVIGATE_OUT:
// Do something that backs out one level of a navigation hierarchy or collapses
// the item that currently has focus.
return true;
default:
// If you did not handle, then let it be handled by the next possible element as
// deemed by Activity.
return super.onKeyDown(keyCode, event);
}
}

关于java - 应用程序中的 Android Wear 手势(版本 1.4),不仅仅用于通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35399713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com