Calling function to show/hide imageviews from another class
<p>In my MainActivity class I have this method:</p>

<p>MainActivity.java</p>

<pre><code>public void ClearImageViews() {
  final ImageView image_a = (ImageView)findViewById(R.id.image_a);
  image_a.setVisibility(View.INVISIBLE);
 }
</code></pre>

<p>And in another file I have another class, which calls ClearImageViews method like this:</p>

<pre><code> MainActivity mainActivity = new MainActivity();
 mainActivity.ClearImageViews();
</code></pre>

<p>Im getting NullPointerExpection while running the code from findViewById function. When I comment out these lines:</p>

<pre><code> final ImageView image_a = (ImageView)findViewById(R.id.image_a);
 image_a.setVisibility(View.INVISIBLE);
</code></pre>

<p>The code works well. What am I doing wrong? </p>
