原文:
1.安装对应dll
Update-Package Xamarin.Forms
选中Android项目及PCL项目:Install-Package Xamarin.Forms.Labs
2.设置系统相关信息,右键android项目-属性
3.设置应用的名称
4.在MainActivity设置IOC
添加变量:private static bool _initialized;修改MainActivity集成自:XFormsApplicationDroid添加方法:
private void SetIoc() { var resolverContainer = new SimpleContainer(); var app = new XFormsAppDroid(); app.Init(this); resolverContainer.Register(t => AndroidDevice.CurrentDevice) .Register (t => t.Resolve ().Display) .Register (resolverContainer) .Register (app); Resolver.SetResolver(resolverContainer.GetResolver()); _initialized = true; }
在OnCreate的base.OnCreate(bundle); 语句下添加
if (!_initialized) { this.SetIoc(); }
如下图:
posted on 2015-05-13 09:43 阅读( ...) 评论( ...)