示例#1
0
        public override void OnCreate()
        {
            // This will be called whenever anything happens for the first time - including a receiver or service being started.

            _current = new WeakReference <NativeDroidApplication>(this);

            ViewPump.Init(ViewPump.InvokeBuilder()
                          .AddInterceptor(new BindingInterceptor())
                          .Build());

            // Register the view model to view mappings
            foreach (var mapping in GetViewModelToViewMappings())
            {
                ViewModelToViewConverter.AddMapping(mapping.Key, mapping.Value);
            }

            // Register splash mappings
            foreach (var mapping in GetViewModelToSplashMappings())
            {
                ViewModelToViewConverter.AddSplashMapping(mapping.Key, mapping.Value);
            }

            // Register the obtain dispatcher function
            PortableDispatcher.ObtainDispatcherFunction = () => { return(new AndroidDispatcher()); };

            // Register message dialog
            PortableMessageDialog.Extension = (messageDialog) => { AndroidMessageDialog.Show(messageDialog); return(Task.FromResult(true)); };

            PortableLocalizedResources.CultureExtension = GetCultureInfo;

            // Initialize the app
            PortableApp.InitializeAsync((PortableApp)Activator.CreateInstance(GetPortableAppType()));

            base.OnCreate();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            var builder = ViewPump.InvokeBuilder();

            builder.AddInterceptor(new ShadowsInterceptor(this, new ShadowLogger()));
            ViewPump.Init(builder.Build());
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            global::Android.Support.V7.Widget.Toolbar toolbar = FindViewById <global::Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            var vv = new View(this);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;
        }