title: Trying to setDisplayHomeAsUpEnabled(true) in my Android app and it's giving me a NullPointerException
body: <p>I have my app as a single Activity with different fragments. I navigate the fragments via the Navigation Drawer on the left. The thing is that I need to have different toolbars for each fragment.</p>
  
  <p>What I did was set the toolbar in the layout of the fragment like so:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.hectorviov.###.activity.HomeFragment"&gt;
  
      &lt;include
          android:id="@+id/toolbar_logo"
          layout="@layout/toolbar_logo" /&gt;
  ...
  </code></pre>
  
  <p>And set it as SupportActionBar on my fragment with with:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      AppCompatActivity act = (AppCompatActivity)getActivity();
  
      Toolbar mToolbar = act.findViewById(R.id.toolbar_logo);
  
      act.setSupportActionBar(mToolbar);
  }
  </code></pre>
  
  <p>It works correctly, the thing is, it doesn't show the hamburger icon on the left of the action bar. It shows me a warning:</p>
  
  <pre><code>W/ActionBarDrawerToggle: DrawerToggle may not show up because NavigationIcon is not visible. You may need to call actionbar.setDisplayHomeAsUpEnabled(true);
  </code></pre>
  
  <p>So I tried different ways to do this after googling a lot. The last one I tried is:</p>
  
  <pre><code>((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true);
  </code></pre>
  
  <p>And no matter what I try, it always gives me a NullPointerException:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hectorviov.###/com.hectorviov.###.activity.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object reference
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
  </code></pre>
  
  <p>Please help!!</p>