I'm using fragment based navigation, each fragment has it's own toolbar.
When navigating to a fragment I want the back button to display in the toolbar.
I have overridden the OnCreateView method as follows:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(_fragmentId, null);
_toolbar = view.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
if (_toolbar != null)
{
ParentActivity.SetSupportActionBar(_toolbar);
ParentActivity.SupportActionBar.Title = _title;
ParentActivity.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
_drawerToggle = new MvxActionBarDrawerToggle(
Activity,
(ParentActivity as MainView).DrawerLayout,
_toolbar,
Resource.String.drawer_open,
Resource.String.drawer_close);
(ParentActivity as MainView).DrawerLayout.AddDrawerListener(_drawerToggle);
}
return view;
}
SetDisplayHomeAsUpEnabled(true) should be changing the button to the back button, according to numerous other stack overflow answers, However this is not working as can be seen in the following screenshot:
I have checked that the SetDisplayHomeAsUpEnabled(true) line is hit when I navigate to the fragment.
For reference I am using Xamarin with MvvmCross.
How do I make change the toolbar to the up/back button when using fragment based navigation?