My goal: i want to show a popupmenu next to a osmdroid-marker
My problem:
Currently i am attaching the menu to an image that is in the lower right corner but may be far away from the current marker.
This is my current code (from https://github.com/k3b/AndroFotoFinder/blob/FDroid/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/LocationMapFragment.java )
public class LocationMapFragment extends DialogFragment {
...
protected boolean showContextMenu(final View parent, final int markerId,
final IGeoPoint geoPosition, final Object markerData) {
MenuInflater inflater = getActivity().getMenuInflater();
// currently the contextmenu is attached to some image "this.mImage"
// which does not correspont to "geoPosition"
// How to create a temporary 1x1 view at "geoPosition"
// where i can attach the menu to?
PopupMenu menu = new PopupMenu(getActivity(), this.mImage);
inflater.inflate(R.menu.menu_map_context, menu.getMenu());
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.cmd_gallery:
return showGallery(getiGeoPointById(markerId, geoPosition));
case R.id.cmd_zoom:
return zoomToFit(getiGeoPointById(markerId, geoPosition));
default:
return false;
}
}
});
menu.show();
return true;
}
}
My question: is there a simple way to create a temporary 1x1 pixel window on top of my marker at IGeoPoint geoPosition
where i can attach the popup to?
Or is there any other simple way to position the menu?
Use the OSMBonusPack Marker InfoWindow (Marker bubble).
You can get its view with infowindow.getView(), and this is a regular android.view.View.
You can design its layout to make it as small as needed.