I'm writing an Android application that targets 4.0 and up and I'm using Google Maps v2. I'd like to set the contents of an InfoWindow
with a Fragment
. Does anyone know if it's possible?
My class implements InfoWindowAdapter
and here's the relevant code:
//
// InfoWindowAdapter interface
//
@Override
public View getInfoContents (Marker marker) {
LinearLayout layout = new LinearLayout(this.getActivity());
LayoutInflater inflater = (LayoutInflater) this.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.map_details, layout);
MapDetailsFragment frag = new MapDetailsFragment();
// TODO: How to add this fragment to v???
return v;
}
@Override
public View getInfoWindow (Marker marker) {
return null;
}
I've tried the following code after instantiating frag
:
this.getFragmentManager().beginTransaction().replace(R.id.fragment_map_details, frag).commit();
But R.id.fragment_map_details
is from the R.layout.map_details
and thus the FragmentManager
doesn't know anything about it yet.
Any pointers would be greatly appreciated!