SupportMapFragment为NULL

时间:2014-08-28 20:37:10

标签: android google-maps xamarin xamarin.android supportmapfragment

下面的方法创建要在应用片段中显示的地图。但它返回NULL。

axml文件:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/mapGoolgle"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   class="com.google.android.gms.maps.SupportMapFragment" />

活动文件:

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = base.OnCreateView(inflater,container,savedInstanceState);

    initMap();

    return v;
}
private void initMap(){

    _mapFragment = (SupportMapFragment) FragmentManager.FindFragmentById (Resource.Id.mapGoolgle);  //return null

    _googleMap = _mapFragment.Map;

    _googleMap.MyLocationEnabled = true;

    _googleMap.MapType = GoogleMap.MapTypeNormal;
}`

0 个答案:

没有答案