title: Android: How to retrieve Activity parent from a fragment inside a ViewPager
body: <p>From my fragment, inside a <strong>ViewPager</strong>, I want to get the parent Activity:</p>
  
  <p>Method in my Fragment:</p>
  
  <pre><code>@Override
  public void setMenuVisibility(final boolean visible) {
      super.setMenuVisibility(visible);
      if (visible) {
         Activity aa = getActivity(); &gt;&gt;&gt; It's always NULL !!
         aa.findViewById(R.id.my_special_button).setVisibility(View.VISIBLE);
      }
  }
  </code></pre>
  
  <p>The layout of this Activity:</p>
  
  <pre><code>&lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"&gt;
  
   ....
  
   &lt;android.support.v4.view.ViewPager
     android:id="@+id/pager"
     android:layout_width="match_parent"
     android:layout_height="match_parent" /&gt;
   ....
  
   &lt;Button
       android:id="@+id/my_special_button"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:background="@color/background"/&gt;
  </code></pre>
  
  <p></p>