从操作栏下拉菜单 - 允许拖放图标绘制到屏幕

时间:2023-01-16 14:37:50

as the title suggests I'm trying to add code to my app which allows the user to click on an item in the action bar menu which then unfolds a drop down menu (spinner class?) containing a few options such as lamp, tv etc. - each with an icon. The user will then be able to select one of these and drag and drop the icon (or an image representing the icon) to the canvas where it is then drawn. What is the best way to go about this?

正如标题所示,我正在尝试将代码添加到我的应用程序中,允许用户单击操作栏菜单中的项目,然后展开一个下拉菜单(微调器类?),其中包含一些选项,如灯,电视等 - 每个都有一个图标。然后,用户可以选择其中一个,然后将图标(或表示图标的图像)拖放到画布上,然后绘制它。最好的方法是什么?

1 个解决方案

#1


0  

If you're referring to the ActionBar overflow menu items, then you would have to take a look at the code for the ActionBar in the framework and extend it in your application, but that would firstly require quite a hassle and secondly would break compatibility when changes are made to the ActionBar in new versions of Android.

如果您指的是ActionBar溢出菜单项,那么您将不得不在框架中查看ActionBar的代码并在您的应用程序中扩展它,但这首先需要相当麻烦,其次会破坏兼容性在新版Android中对ActionBar进行了更改。

Also, this goes completely away from what the ActionBar is intended to be. You should only have actions in the overflow menu, not contain elements that directly interact with the Activity content. It's just wrong. Consider redesigning your UI so that you implement the requested featured inside the content view, not on the ActionBar.

而且,这完全不同于ActionBar的目的。您应该只在溢出菜单中有操作,不包含直接与活动内容交互的元素。这是错的。考虑重新设计UI,以便在内容视图中实现所请求的功能,而不是在ActionBar上。

#1


0  

If you're referring to the ActionBar overflow menu items, then you would have to take a look at the code for the ActionBar in the framework and extend it in your application, but that would firstly require quite a hassle and secondly would break compatibility when changes are made to the ActionBar in new versions of Android.

如果您指的是ActionBar溢出菜单项,那么您将不得不在框架中查看ActionBar的代码并在您的应用程序中扩展它,但这首先需要相当麻烦,其次会破坏兼容性在新版Android中对ActionBar进行了更改。

Also, this goes completely away from what the ActionBar is intended to be. You should only have actions in the overflow menu, not contain elements that directly interact with the Activity content. It's just wrong. Consider redesigning your UI so that you implement the requested featured inside the content view, not on the ActionBar.

而且,这完全不同于ActionBar的目的。您应该只在溢出菜单中有操作,不包含直接与活动内容交互的元素。这是错的。考虑重新设计UI,以便在内容视图中实现所请求的功能,而不是在ActionBar上。