문제

In Android is it possible to register a View for context menu, so that the menu will show up when it is double tapped instead of when a long press action has been registered? I have a view with a scroll functionality. This view is also registered for a context menu. Whenever a scroll is performed on this view and the scroll action takes a certain amount of time the long press action is triggered and the context menu pops up. In order to avoid this situation I would like to make the context menu appear when the view is double tapped rather than when it is pressed long.

도움이 되었습니까?

해결책

For anyone who has run into this problem. What I ended up doing was to listen for the long press with the GestureListener. Once the long press event is triggered, I register the view for a context menu with registerForContextMenu(View v), then call openContextMenu(View v).

And in order to not have the context menu pop up and interfere with the long press event, I overrode the onContextMenuClosed(Menu menu) method, in which I call unregisterForContextMenu(View v) passing the view that I earlier registered.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top