title: android getSupportActionBar() returns null in fragment
body: <p><strong><em>UPDATE</em></strong></p>
  
  <p>I had not mentioned anything about using <a href="http://developer.android.com/reference/android/support/v7/widget/Toolbar.html" rel="nofollow noreferrer">ToolBar</a> with <code>ActionBarActivity</code>. And that is the reason I always get null pointer exception. For those who face same problem <a href="https://stackoverflow.com/a/29124350/2054829">please refere this answer</a> </p>
  
  <hr>
  
  <p>I have this fragment code to change appearance of support action bar when fragment is changed. </p>
  
  <pre><code>@Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          setHasOptionsMenu(true);
          mActionBar = ((ActionBarActivity)getActivity()).getSupportActionBar();
          SpannableString s = new SpannableString("Dashboard");
          s.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.app_blue_text)), 0, s.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
          s.setSpan(new TypefaceSpan(getActivity(), "Optima-Regular.ttf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  
          if( null!= mActionBar){
              mActionBar.setElevation(0);
              mActionBar.setTitle(s);
          }
      }
  </code></pre>
  
  <p>I've referred previous/similar questions regarding how to solve this error. Those solutions suggest to change actionbar appearance in <code>onActivityCreated()</code> method. I tried <code>onAttach()</code> also. None seems to work. I have used support actionbar to maintain backward compatibility. <code>Activity</code> is also casted accordingly to <code>ActionBarActivity</code>.</p>
  
  <p>Complete code is pretty much lengthy so I have skipped posting it. If needed I can post complete code and update question with more details as well. </p>
  
  <p><strong>Error log</strong></p>
  
  <pre><code>Caused by: java.lang.NullPointerException
              at com.example.testapp.fragments.NavigationDrawerFragment.onActivityCreated(NavigationDrawerFragment.java:215) 
  </code></pre>
  
  <p>Line 215 is : <code>mActionBar.setElevation(0);</code></p>