title: How to setImageResource of a dynamically declared ImageButtons?
body: <p>I have some dynamically declared <code>ImageButtons</code>, these <code>ImageButtons</code> don't have ids' and they are declared in a <code>LinearLayout</code>, I want to create a method to change Images resources of these <code>ImageButtons</code> when called, and as I don't have a predefined ids' for these <code>ImageButtons</code> I'm using the function <code>getChildAt()</code> with the <code>LinearLayout</code>, but <code>getChildAt()</code> doesn't provide <code>setImageResource()</code>, it just provide <code>setBackgroundResource()</code> and this function doesn't make a replacement to the old Image and also doesn't fit at the old Image as it provides a <strong>background</strong> not an <strong>Image Resource</strong>, what can I do with that ? </p>
  
  <p>this is my method code :</p>
  
  <pre><code>private void my_method(int drawable) {
  
          int count = Righter.getChildCount(); // Righter is the LinearLayout
          for (int i = 1; i &lt; count; i++) {
              Righter.getChildAt(i).setBackgroundResource(drawable); // here is where i change the background image 
              Righter.getChildAt(i).setClickable(true);
          }
  
      }
  </code></pre>