title: Android: cannot resolve symbol "setImageResource"
body: <p>I am trying to change the image for an ImageButton in my Java code, but I keep getting an error message "cannot resolve symbol "setImageResource".</p>
  
  <p>The ImageButton is defined in my XML as follow:</p>
  
  <pre><code>&lt;ImageButton
      android:id="@+id/button_ir2"
      android:layout_width="60dp"
      android:layout_height="50dp"
      android:layout_marginBottom="10dp"
      android:layout_marginRight="5dp"
      android:background="@android:color/white"
      android:src="@drawable/img1"
      android:scaleType="fitCenter"/&gt;
  </code></pre>
  
  <p>And in my Java code:</p>
  
  <pre><code>            final View vz=findViewById(R.id.button_ir2);
              ImageButton aButton = (ImageButton)vz;
              aButton.setImageResource(R.drawable.img2);
  </code></pre>
  
  <p>I think I am typecasting this correctly, but maybe not. Spent almost a day on this, any help will be greatly appreciated.</p>