2013-08-07 43 views
0

是否可以將佈局添加到MvxSplashScreenActivity?我在其他所有活動overiden的OnViewModelSet一樣,放在下面的代碼:將佈局添加到閃屏

protected override void OnViewModelSet() 
    { 
     base.OnViewModelSet(); 
     SetContentView (Resource.Layout.SplashScreen); 
    } 

我試圖加載的佈局是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:minWidth="25px" 
android:minHeight="25px"> 
<ImageView 
    android:src="@drawable/applogo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageView1" 
    android:layout_centerInParent="true" /></RelativeLayout> 

,我收到以下異常:

Cirrious.CrossCore.Exceptions.MvxException:無法解析類型 Cirrious.MvvmCross.Binding.BindingContext.IMvxBindingContextStack`1 [Cirrious.MvvmCross.Binding.Droid.BindingContext.IM vxAndroidBindingContext, Cirrious.MvvmCross.Binding.Droid,版本= 1.0.0.0,文化=中立, 公鑰=空]

我似乎無法在網上找到關於mvvmcross閃屏什麼..

Ahy的想法?

回答

1

不能在splashscreen內使用數據綁定佈局 - 在mvvmcross完全啓動之前會顯示splashscreen。

然而,對於一個簡單的佈局,你通過一個資源ID下到基類的構造函數:

public class SplashScreen : MvxSplashScreenActivity 
{ 
    public SplashScreen() 
     : base(Resource.Layout.SplashScreen) 
    { 
    } 
} 

而且 - 爲了避免黑啓動屏幕 - 大多數人使用一個主題來指定一個全屏幕圖像在他們的啓動畫面中 - 參見nuget提供的'標準'啓動畫面 - https://github.com/slodge/MvvmCross/blob/v3/nuspec/DroidContent/SplashScreen.cs.pp

0

確保在調用OnCreate之前初始化安裝程序。

protected override void OnCreate(Bundle bundle) 
     { 
      var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this); 
      setupSingleton.EnsureInitialized(); 

      base.OnCreate(bundle); 
     }