How does MVVMCross fragment navigation work in 4.0

2019-06-04 07:38发布

问题:

Since the new upgrade I have no idea on how to navigate with fragments.

A lot of code from here is commented out. If I use the code that is left, it doesn't work. I get the activity not found exception. I use the same headers as written in demo example. What are the steps I need to follow to create a succesful fragment?

回答1:

The new fragments are actually pretty straight forward. All you have to do is annotating your fragment classes with the MvxFragmentAttribute and then making sure that the type passed as the first argument of the MvxFragmentAttribute implements IMvxFragmentHost, so that it can handle the Open and Close methods used by the MvxFragmentsPresenter.

The new MvxFragmentsPresenter will handle whether or not the current top Activity is responsible for showing the requested fragment or not and, if it isn't, it'll start the proper activity in before showing the fragment.