Sony Smart Watch 2: How to prevent CLICK_TYPE_SHORT from being called after button long click?

微笑、不失礼 提交于 2019-12-11 10:27:01

问题


I use a ControlExtension for Sony SmartWatch 2 and I have a click-handler:

@Override
public void onObjectClick(final ControlObjectClickEvent event) {
    switch (event.getClickType())
    {
        case Control.Intents.CLICK_TYPE_LONG:
        Log.i("onObjectClick", "long press");
        break;

        case Control.Intents.CLICK_TYPE_SHORT:
        Log.i("onObjectClick", "press");
        break;
    }
}

When I click on the button, I get press in my LogCat as expected.
When I hold the button I get long press (just as I want it).
But when I release the button after a long-press, I get press again.

How can I change this behavior?


回答1:


Have you tried handling a long click like this?

ControlView upperLeft = mLayout.findViewById(R.id.sample_control_object_1);
upperLeft.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public void onLongClick() {
                // handle click action here
            }
        });


来源:https://stackoverflow.com/questions/22616429/sony-smart-watch-2-how-to-prevent-click-type-short-from-being-called-after-butt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!