开发者

Open Android options menu from method

开发者 https://www.devze.com 2023-04-01 11:23 出处:网络
I know that it\'s possible because I\'ve done it before, but i los开发者_JAVA百科t my code. I want to open the Menu from an touch event. What do I need to write to open it? I really don\'t know anymor

I know that it's possible because I've done it before, but i los开发者_JAVA百科t my code. I want to open the Menu from an touch event. What do I need to write to open it? I really don't know anymore.


You need to override onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo) and onContextItemSelect() in activity.

If you want it to appear on long click then call registerForContextMenu(View). If you want to show it manually on clicking any view then call openContextMenu() in onClick().

0

精彩评论

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