I am adding a Map to a fragment with this code:
public class MapFragment : Fragment
{
private MapActivity map=null;
public override Android.Views.View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return new FrameLayout(Activity);
}
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
map = new MapView(Activity,"XXXXX-v0jt5Z-XXXXXX");
//HOW TO ADD THE VIEW HERE???
}
}
My question is, in Mono for Android how to I add the Map to the View.
Note: In Java I would write this:
((ViewGroup)getView()).addView(map);
Footnote: This example uses code from the Java MapFragment source code: https://github.com/commonsguy/cw-omnibus/blob/master/Maps/NooYawkFragments/src/com/commonsware/android/mapfrags/MapFragment.java
Maps can not be added to Fragments as is, they need a hosting environment.
Here’s the solution for a MapFragment: