title: Imagebutton change programmatically?
body: <p>I'm trying to change the image of the ImageButton programmatically.</p>
  
  <p>I'm trying to copy this code, but the setBackgroundDrawable is already deprecated.</p>
  
  <pre><code>public void giveClue(View view) {
      Drawable replacer = getResources().getDrawable(R.drawable.icon2);
      ((ImageButton) view).setEnabled(false);
      ((ImageButton) view).setBackgroundDrawable(replacer);
      gameAdapter.giveClue(game);
  }
  </code></pre>
  
  <p>My button was created using xml as follows:</p>
  
  <pre><code>   &lt;ImageButton
          android:id="@+id/ImageButton2"
          android:layout_width="24dp"
          android:layout_height="22dp"
          android:layout_alignTop="@+id/imageButton1"
          android:layout_toLeftOf="@+id/ImageButton3"
          android:src="@drawable/icon" 
          android:onClick="giveClue"/&gt;
  </code></pre>