【发布时间】:2014-03-16 17:08:20
【问题描述】:
我处于一种奇怪的情况,我无法将 Fragment 转换为 SupportMapFragment。而且我已经阅读了 8+ 个关于类似问题的主题,这些主题都与我的问题无关。他们都混合了 MapFragment 和 SupportMapFragment,或者引用了 Android.App 而不是 Android.Support.V4.App。
我在 Mono (MvvmCross) 中。我的布局包含一个 SupportMapFragment。
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
所以,下面是我尝试从布局中获取 SupportMapFragment 的方法:
var theMap = (SupportMapFragment) SupportFragmentManager
.FindFragmentById(Resource.Id.map);
Cannot cast expression of type 'Android.Suport.V4.App.Fragment'
to type 'SupportMapFragment'
SupportMapFragment 继承自 android.support.v4.app.Fragment,所以我觉得它很奇怪。
我引用了 Mono.Android.Support.v4 和 Xamarin.Android.Support.V4。
我注意到我的 SupportFragmentManager 来自 global::Android.Support.V4.App,而不是前面提到的两个程序集。
我的项目针对 API 13 到 19,并在 API 19 中编译。
我正在使用 Cirrious.MvvmCross.Droid.Fragging 的预编译版本,因为组件中的版本无法构建。
简而言之:我从SupportFragmentManager 得到的不能转换为SupportMapFragment。
【问题讨论】:
标签: xamarin.android supportmapfragment