How to enable Drag a Marker (Android Map Api v2) after a single Touch?

自作多情 提交于 2019-12-10 17:23:46

问题


I have a map with some markers. I set the listener for drag:

map.setOnMarkerDragListener(this);

But the drag is enable only after the user long press the marker. I want to enable drag immediately. Is there a way to do this with Android Maps (v2)?


回答1:


You can use Drag and Drop, with the Android drag/drop framework, you can allow your users to move data from one View to another view in the current layout using a graphical drag and drop gesture. The framework includes a drag event class, drag listeners and helper methods and classes.

A drag and drop operation starts when the user makes some gesture that you recognize as a signal to start dragging data. In response, your application tells the system that the drag is starting. The system calls back to your application to get a representation of the data being dragged. As the user's finger moves this representation (a "drag shadow") over the current layout, the system sends drag events to the drag event listener objects and drag event callback methods associated with the View objects in the layout.

You create a drag event listener object ("listeners") from a class that implements View.OnDragListener. You set the drag event listener object for a View with the View object's setOnDragListener() method. Each View object also has a onDragEvent() callback method. Both of these are described in more detail in the section The drag event listener and callback method.



来源:https://stackoverflow.com/questions/38934224/how-to-enable-drag-a-marker-android-map-api-v2-after-a-single-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!