MvxActivities
are an extended object from a regular Android Activity
; the app knows we are using the MVVMCross binding system.
Let's implement MainPageMvxActivity
:
[Activity(Label = "Audio Player")] public class MainPage : MvxActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetupIoC(); SetContentView(Resource.Layout.MainPage); } private void SetupIoC() { Mvx.RegisterType<ISoundHandler, SoundHandler>(); PortableMvxIoCRegistrations.InitIoC(); } }
We will need to set up our IoC registrations in the IoC container when this activity is created. Then we simply set the content view to the XML sheet we created previously. Let's test out the Android application and click run; you should now have a MainPage
screen like this:
Now we move on to the fun part: let's add a new .xml
and MvxActivity
for the AudioPlayerPage...