1. Install the corresponding DLL update-package xamarin.forms Select Android Project and PCL project: Install-package Xamarin.Forms.Labs2. Set system-related information, right-click Android Project-Properties
3. Set the name of the app
4. Set IOC in Mainactivity
Add Variable: private static bool _initialized; modified mainactivity integrated from: Xformsapplicationdroid To Add a method:
private void Setioc () { var resolvercontainer = new Simplecontainer (); var app = new Xformsappdroid (); App. Init (this); Resolvercontainer.register<idevice> (t = androiddevice.currentdevice) . Register<idisplay> (t = t.resolve<idevice> (). Display) . Register<idependencycontainer> (Resolvercontainer) . Register<ixformsapp> (app); Resolver.setresolver (Resolvercontainer.getresolver ()); _initialized = true; }
in the OnCreate base.oncreate (bundle), add the statement under the
if (!_initialized) {this . SETIOC (); }
such as:
Learn xamarin.forms from scratch (iv) Android prep Step (add third-party Xamarin.Forms.Labs library)