Does anyone know how to create a message bubble with 2 buttons appears on top of an overlayitem for map application using android 2.1?

StackOverflow https://stackoverflow.com/questions/2484092

Question

I currently have implemented an overlay item that shows an icon for Geo-point on a map application in Android. When the icon is clicked, it brings up an AlertDialog from the onTap method below. I have the following questions:

  1. Does anyone know how to display a map message bubble directly above the icon overlayitem with 2 callout buttons one to the left of the title and one to the right of the bubble?
  2. Does anyone know how to make the overlayitem draggable so I can press and hold it and drag it across the map. I am trying to duplicate the draggable icon behaviour that's available on the iPhone.

If so, please share some sample code. Thanks

protected boolean onTap(int index) {  
    OverlayItem item = mOverlays.get(index);  
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);  
    dialog.setTitle(item.getTitle());  
    dialog.setMessage(item.getSnippet()); 
    dialog.show();  
    return true;
}
Was it helpful?

Solution

As for #1, you can see how to create popup panels in this sample project from one of my books.

As for #2, I do not believe it is possible, strictly speaking. Certainly, there is nothing built in for that, at least that I have seen. You could attempt to detect a touch event, get rid of the existing overlay item, draw your own copy of the icon where the overlay item had been, manually animate that as the user drags, and then put the overlay item where the user drops it (getting rid of your manually-drawn icon).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top