title: How to change ImageView source in android
body: <p>This is my xml, this is located inside a fragment that appears in my activity.</p>
  
  <pre><code>&lt;FrameLayout
                      android:id="@+id/frame1"
                      android:layout_width="wrap_content"
                      android:layout_height="115dp"
                      android:layout_margin="2dp"
                      android:layout_weight="0.33"&gt;
  
                      &lt;ImageView
                          android:id="@+id/whoamiwith"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:scaleType="fitCenter"
                          android:src="@drawable/default_image" /&gt;
                  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>And this is my java code : </p>
  
  <pre><code>@Override
  public void onClick(View click) {
      if (click == profileBtn) {
          whoamiwith.setBackgroundResource(R.drawable.image_i_wanna_put);
      }
  }
  </code></pre>
  
  <p>I am trying to change the image source of the image view. There are no syntax errors but when I click the button the emulator is giving me a force close and on the logcat it says:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException</p>
  </blockquote>
  
  <p>It's pointing to the line:  </p>
  
  <pre><code>whoamiwith.setBackgroundResource(R.drawable.loginbtn);
  </code></pre>