title: Initialised ImageButton in other Activity throws nullPointerException when referenced in MainActivity
body: <p>I'm very new to Android and Java coding in general, so bear with me if I don't understand basic concepts.. This is just a test to see if something works, so It might not initially make any sense.</p>
  
  <p>I have two activities, Main and Other. 
  the Other Activity has an imageButton with visibility initially set to invisible.
  When MainActivity is created, it should look for that imageButton in the Other activity, and set it's view to visible. </p>
  
  <p>Though when debugging, all I get is a nullPointerException, because the button has null as value. How can I make it reference the button?</p>
  
  <p>Part of Main Activity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      pstep();
  }
  
  
  public void pstep() {
      int pstep = 0;
      ImageButton panfav = (ImageButton) findViewById(R.id.favpancake);
      panfav.setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>Part of Other Activity:</p>
  
  <pre><code>public class navfav extends AppCompatActivity {
  ImageButton panfav = (ImageButton) findViewById(R.id.favpancake);
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.navfav);
  }
      public void fab(View v){
      ImageButton panfav = (ImageButton) findViewById(R.id.favpancake);
      panfav.setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>XML linked to Other Activity:</p>
  
  <pre><code>    &lt;ImageButton
      android:id="@+id/favpancake"
      android:layout_width="wrap_content"
      android:layout_height="137dp"
      android:layout_alignParentStart="true"
      android:layout_below="@+id/imageView3"
      android:background="@android:color/background_dark"
      android:contentDescription="@string/nav_cook_dish"
      android:onClick="fab"
      android:scaleType="centerCrop"
      android:src="@drawable/dishpancake"
      android:visibility="invisible" /&gt;
  </code></pre>
  
  <p>Log:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void 
  android.widget.ImageButton.setVisibility(int)' on a null object reference
  
  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 
  'void android.widget.ImageButton.setVisibility(int)' on a null object reference
  at com.p2.rookie.MainActivity.pstep(MainActivity.java:23)
  at com.p2.rookie.MainActivity.onCreate(MainActivity.java:16)
  </code></pre>
  
  <p>Shoot if I'm missing anything you need to use, I'll provide as much as i can :)
  Best</p>