开发者

Can we provide drag and drop capability to menu item of optionsmenu in android

We can create a view and provide drag and drop functionality to any view. I have 3 images in horizontally in the left image1, in center image2 and in the right most image3 is set. Now we can drag image3 t开发者_运维问答o image 1 or image2 position. To achieve that we have to write custom listeners for drag and drop. Similar thing I want to get for menu items. I want to drag first menu item to last position when the application is running. I am able to create menu item using the code given in the following link.

http://www.tutorialforandroid.com/2009/01/icons-in-options-menu-in-android-code.html

Is there any way to provide drag and drop capability to Menu item in optionsMenu?


I don't believe this is possible without creating a custom options menu that is separate from the built-in Android options menu. There are 2 reasons for this.

1) When a user touches a MenuItem in any way, the selection is not triggered until the touch is released from the item. There is not a clean way to tell if the user had pressed the MenuItem for a quarter of a second or for a minute. This would make it extremely difficult to even distinguish if the user was selecting an item or wanted to drag and drop it.

2) MenuItems can't be cast to Views and are part of the private API, and as such there isn't a way for you to get any sort of positioning data out of them other than their relative position within the OptionsMenu.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜