【发布时间】:2018-01-06 21:30:35
【问题描述】:
我开始学习 MVVM 交叉,在 android 应用程序中,我有一个闪屏类:
[Activity(MainLauncher = true,
Label = "@string/app_name",
Theme = "@style/Theme.Splash",
NoHistory = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashScreen : MvxSplashScreenActivity
{
public SplashScreen() : base(Resource.Layout.SplashScreen)
{
}
}
这是设置类:
public class Setup : MvxAndroidSetup
{
protected Setup(Context applicationContext) : base(applicationContext)
{
}
protected override IMvxApplication CreateApp()
{
return null;
}
}
问题是调试器没有命中设置类的构造函数,而是在启动屏幕的构造函数之后得到“未处理的异常”
编辑
我已经在 PCL 项目中定义了 App 类:
public class App : MvxApplication
{
public override void Initialize()
{
base.Initialize();
}
还定义了 AppStart:
public class AppStart : MvxNavigatingObject, IMvxAppStart
{
public async void Start(object hint = null)
{
//hardcoded login for this demo
//var userService = Mvx.Resolve<IUserDataService>();
//await userService.Login("gillcleeren", "123456");
ShowViewModel<MainViewModel>();
}
}
这个项目背后的主要原因是为了了解 MVVM Cross 所需和执行的代码序列,所以我提供了最少的代码,直到它成功运行而没有运行时错误。
【问题讨论】:
标签: c# android xamarin mvvm mvvmcross