In my Xamarin Android, I want to resolve v4.fragment manager so, I'm resolving it in the following way
var ss = Mvx.Resolve<Android.Support.V4.App.FragmentManager>();
But, I'm getting error:
MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to resolve type Android.Support.V4.App.FragmentManager
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.Resolve (System.Type t) [0x0001c] in D:\git\MvvmCross\MvvmCross\Platform\Platform\IoC\MvxSimpleIoCContainer.cs:199
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.Resolve[T] () [0x00000] in D:\git\MvvmCross\MvvmCross\Platform\Platform\IoC\MvxSimpleIoCContainer.cs:189
at MvvmCross.Platform.Mvx.Resolve[TService] () [0x00005] in D:\git\MvvmCross\MvvmCross\Platform\Platform\Mvx.cs:34
at TJX.Core.IoC.MvxDependencyResolver.ResolveType[T] () [0x00001] in /Users/ali00261/Loyalty-MultiBanner-Mobile/TJX.Core/IoC/MvxDependencyResolver.cs:11
Can anyone advice what am I doing wrong and how to resolve it ? Thanks.
UPDATE
I want to replace a FrameLayout in my MvxFragment<TViewModel>
with a support.v4.fragment.
ZXingScannerFragment
is a support.v4.Fragment provided by 'ZXing' to scan barcode.
var scanFragment = new ZXingScannerFragment();
var ss = Mvx.Resolve<Android.Support.V4.App.FragmentManager>();
ss.BeginTransaction()
.Replace(Resource.Id.fragment_scancontainer, scanFragment)
.Commit();
My aim is to replace a view(frame layout) with a support.v4.Fragment
You can use the ChildFragmentManager
to support managing Fragments inside of Fragments.
ChildFragmentManager.BeginTransaction()
.Replace(Resource.Id.fragment_scancontainer, scanFragment)
.Commit();
In terms of App.Fragment
vs Support.V4.App.Fragment
, it looks like you are using the wrong dependencies.
Mvvmcross offer two MvxFragment
class type to match those offered in Android:
MvvmCross.Droid.FullFragging.Fragments.MvxFragment
. This class matches to the native Android Fragment
introduced in API 11.MvvmCross.Droid.Support.V4.MvxFragment
. This class matches to the Android Support Library Fragmets.You need to use the Support Library Fragment version of MvxFragment
in order to use Support.V4.App.Fragment
with a ChildFragmentManager
.