c# - Custom android toolbar back button not showing -


i want show custom toolbar, , show home(hamburger) icon , arrow icon, when navigate other fragments.

home button shown, arrow not.

my app using mvvmcross, , have main host activity, manages fragments:

[activity()] public class mainview : mvxcachingfragmentcompatactivity<mainviewmodel> {     private drawerlayout _drawer;     private mvxactionbardrawertoggle _drawertoggle;      protected override void oncreate(bundle bundle)     {         base.oncreate(bundle);          setcontentview(resource.layout.mainview);          var _toolbar = findviewbyid<android.support.v7.widget.toolbar>(resource.id.toolbar);         _toolbar.setnavigationicon(resource.drawable.back_arrow);         setsupportactionbar(_toolbar);         supportactionbar.setdisplayhomeasupenabled(true);         supportactionbar.setdisplayshowhomeenabled(true);         supportactionbar.setdisplayshowtitleenabled(false);          _drawer = findviewbyid<drawerlayout>(resource.id.drawer_layout);         _drawer.setstatusbarbackgroundcolor(resource.color.dark_gray);          _drawertoggle = new mvxactionbardrawertoggle(this, _drawer, resource.string.open_menu, resource.string.close_menu);          _drawer.adddrawerlistener(_drawertoggle);         _drawertoggle.syncstate();     }     //... } 

host layout:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">     <android.support.v4.widget.drawerlayout         android:id="@+id/drawer_layout"         android:layout_width="match_parent"         android:layout_height="match_parent">         <linearlayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:orientation="vertical">             <android.support.design.widget.appbarlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content">                 <android.support.v7.widget.toolbar                     android:id="@+id/toolbar"                     android:layout_width="match_parent"                     android:layout_height="?attr/actionbarsize">                      <include layout="@layout/toolbar"/>                  </android.support.v7.widget.toolbar>             </android.support.design.widget.appbarlayout>             <!-- main content view -->             <framelayout                 android:id="@+id/content_frame"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />         </linearlayout>         <!-- navigation drawer -->         <linearlayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_gravity="start"             android:orientation="vertical">             <framelayout                 android:id="@+id/menu_frame"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />         </linearlayout>     </android.support.v4.widget.drawerlayout> </linearlayout> 

and toolbar layout:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="wrap_content">     <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical">         <textview             android:id="@+id/toolbartitle"             android:maxlines="1"             android:textsize="16sp"             android:text="my title"             android:layout_height="wrap_content"             android:layout_width="wrap_content"             android:gravity="left"             android:layout_marginleft="10dp"             android:layout_margintop="10dp" />     </linearlayout> </relativelayout> 

and have hamburger icon, not turned arrow, or custom arrow not shown when show other fragments. tryed custom variations of supportactionbar properties , setting custom button, result same. how can achieve ?

finally found solution case:

in fragments host class, handle event, when fragment changed, , depending on fragment type, display or home button in toolbar:

public class mainview : mvxcachingfragmentcompatactivity<mainviewmodel> {     public override void onattachfragment(fragment fragment)     {         base.onattachfragment(fragment);         if (fragment mainlistview)         {             setdrawerstate(true);         }         else         {             setdrawerstate(false);         }     }      public void setdrawerstate(bool isenabled)     {         if (isenabled)         {             _drawer.setdrawerlockmode(drawerlayout.lockmodeunlocked);             _drawertoggle.ondrawerstatechanged(drawerlayout.lockmodeunlocked);             _drawertoggle.drawerindicatorenabled = true;             _drawertoggle.syncstate();          }         else         {             _drawer.setdrawerlockmode(drawerlayout.lockmodelockedclosed);             _drawertoggle.ondrawerstatechanged(drawerlayout.lockmodelockedclosed);             _drawertoggle.drawerindicatorenabled = false;             _drawertoggle.syncstate();         }     } } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -