title: AnimationDrawable programmatically without animation-list xml
body: <p>I am in a situation where I want to display animation from dynamic list of images. I want to use AnimationDrawable for this purpose, but unfortunately I am stuck... :( my code is as</p>
  
  <pre><code>ImageView globe = (ImageView) findViewById(R.id.globe);
  
  AnimationDrawable animation = new AnimationDrawable();
  animation.setOneShot(true);
  
  Resources res = this.getResources();
  
  while (from &lt;= to) {
      String name = "globe_" + String.format("%03d", from);
      int globeId = res.getIdentifier(name, "drawable",
              this.getPackageName());
      animation.addFrame(res.getDrawable(globeId), 200);
      from++;
  }
  
  globe.setBackgroundDrawable(animation);
  globe.post(new Runnable(){
          @Override
          public void run() {
              animation.start();
          }
  });
  </code></pre>