title: Hide Floating Action Button after clicking it
body: <p>I'd like to know how to make the Floating Action Bar disappear upon clicking it. The action it performs is within the same fragment so I can't simply load another activity or fragment, which lacks the FAB. I tried to use </p>
  
  <pre><code>fab.setVisibility(view.GONE);
  </code></pre>
  
  <p>in its onClickListener:</p>
  
  <pre><code>FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          writeProfile();
          fab.setVisibility(view.GONE);
      }
  }); 
  </code></pre>
  
  <p>But of course you can't access a variable from within an inner class.</p>
  
  <p>EDIT: The Accepted answer works to hide the FAB but how then can I un-hide the FAB from another method?</p>