简体   繁体   English

Android上下文菜单自定义定位?

[英]Android context menu custom positioning?

I have managed to do this for Toasts and Dialog boxes, but now the trouble of context menu has arisen.我已经设法为 Toasts 和对话框做到了这一点,但现在出现了上下文菜单的麻烦。 Is it possible in Android to position a context menu to a different location programmatically?是否可以在 Android 到 position 中以编程方式将上下文菜单指向不同的位置? I want to be able to specify the position anywhere on the screen as part of a custom user interface, but I cannot seem to figure out how to do this.我希望能够在屏幕上的任何位置指定 position 作为自定义用户界面的一部分,但我似乎无法弄清楚如何做到这一点。 Thanks in advance.提前致谢。

As I noted in my comment, I went with a PopupWindow for the actual menu view.正如我在评论中指出的那样,我使用PopupWindow来查看实际的菜单视图。 It contained a ListView for the menu items with appropriate event listeners.它包含带有适当事件侦听器的菜单项的ListView I attached the context menu by overriding the long press listener and adding the PopupWindow at event.getRawY() .我通过覆盖长按侦听器并在event.getRawY()添加PopupWindow来附加上下文菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM