开发者

How to create context menu on double click?

I need to create context menu on double click as well as on long tapping. How it can be done?

I mean normally onCreateContextMenu called when user press long tap on widget. In my case I need to do the same when user double clicks on widget.

ADDED

I know that it's not really nice option, since it's not normal for Android UI. But my primary problem is to solve UI bugs for devices of some vendors - namely HTC (look this post). I have seemingly resolved described issue, but still I d开发者_C百科o have problems with context menus. So as a last resort I just thought to avoid tapping through double click. Thanx for understanding...


From what I gather, you have context-sensitive actions you want tied to an EditText, and HTC's changes to Android are interfering with that.

First, I would reconsider using context menus in general, as they are not particularly discoverable, so most of your users will never find them.

Second, in the case of the EditText, the odds of users discovering that a double-tap will bring up a context menu will be on par with the odds that the Earth will have an extinction-level asteroid strike today.

:: looks up in sky ::

Rather than a double-tap, one option would be to put a small ImageButton adjacent to the EditText, with a downward-facing arrowhead (akin to a Spinner), and tie that ImageButton to a PopupMenu (ideal, but only API Level 11), a PopupWindow, or an AlertDialog. Or, in a pinch, have the ImageButton display a context menu when clicked via showContextMenu(). This too is non-standard UX, but it is at least more discoverable, as users will be used to things popping up when pressing down-arrow buttons, from both Android and other OSes.

If you are absolutely convinced that you need a double-tap, AFAIK that is not a recognized touch event, so you will need to handle the low-level touch events yourself, determine when a double-tap occurs, and do so in a way that does not interfere with the usage of the EditText (e.g., setting cursor position).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜