2013-08-06 17 views
0

我正在研究一個項目,我可以在其中使用MapFragment或SupportMapFragment作爲自定義控件。 我試圖混合自定義控件(N-18)和Fraggle(N-26)教程,但我無法使其工作。作爲MvvmCross中的自定義控件的Android MapFragment

我的自定義控制類:

public class CustomMapView : MvxFragment 
{ 
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    { 
     var ignored = base.OnCreateView(inflater, container, savedInstanceState); 
     return this.BindingInflate(Resource.Layout.CustomMapViewLayout, null); 
    } 
} 

我CustomMapViewLayout.axml

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

在FirstView.axml我引用CustomMapView:

<cc.CustomMapView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

(I使用ViewNamespaceAbbreviations在Setup.cs)

當我嘗試部署我得到這些錯誤:

MvxBind:錯誤查看類型未找到 - cc.CustomMapView(我敢肯定的命名空間是正確的) Android.Views.InflateException:正在加載...

有沒有人設法解決這種問題?

回答

0

據我所知,片段必須在FragmentActivity父項中使用,必須使用fragment xml標籤或使用其中一個(支持)片段管理器方法加載父視圖組中的動態加載。

報告View Type Not Found - cc.CustomMapView的Mvx代碼絕對不會工作 - 它正在尋找繼承該名稱空間中的Android View的類,而不是查找Fragment

可能有方法來編寫更多的'動態'片段xml代碼 - 但沒有任何mvvmcross貢獻者已經發現了任何這些。就目前而言,我認爲你將不得不更常規地使用片段 - 就像N=26 sample

相關問題