title: Show Back Arrow in Fragment
body: <p>I want to show Back Arrow in Fragments ToolBar. Im trying to write this code:  <code>((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);</code></p>
  
  <p>but AS writes: <strong>method invokation .. may produce "java.lang.NullPointerException".</strong> What about <strong>getSupportActionBar()</strong>, AS writes cannot resolve method. Whats wrong? Here is my code:</p>
  
  <pre><code>public class AddFilterFrag extends android.app.Fragment  {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);       
          setHasOptionsMenu(true);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.add_filter_layout, container, false);
          ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          return rootView;
      }
   @Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
          super.onCreateOptionsMenu(menu, inflater);
  
         inflater.inflate(R.menu.fragment_menu, menu);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          if (item.getItemId() == android.R.id.home) {
              //something to do
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  </code></pre>