2013-08-07 41 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); 
     }