title: Loading bitmap to a menu item in a loop with Picasso
body: <p>The code below is called in a loop. I've read <a href="https://stackoverflow.com/a/26918731/1120126">this SO answer</a> but, since I cannot <code>setTag</code> to a <code>MenuItem</code>, <code>Target</code> gets garbage collected. <code>onBitmapLoaded</code> is not called. How can I solve this issue.</p>
  
  <p>The other question is, at the first launch of the app it doesn't work. How does it work after I call this method again.</p>
  
  <pre><code>private void addServiceToMenu(Service service, final MenuItem menuItem) {
      if (!TextUtils.isEmpty(service.getIconURL())) {
          Resources resources = getResources();
          final int targetWidth = resources.getDimensionPixelSize(R.dimen.menu_icon_size);
          final int targetHeight = resources.getDimensionPixelSize(R.dimen.menu_icon_size);
  
          final Target target = new Target() {
              @Override
              public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                  Drawable drawable = new BitmapDrawable(getResources(), bitmap);
  
                  drawable.setBounds(0, 0, targetWidth, targetHeight);
                  menuItem.setIcon(drawable);
              }
  
              @Override
              public void onBitmapFailed(Drawable errorDrawable) { }
  
              @Override
              public void onPrepareLoad(Drawable placeHolderDrawable) { }
          };
  
          Picasso.with(MainActivity.this).load(service.getIconURL())
                  .resize(targetWidth, targetHeight)
                  .into(target);
      }
  }
  </code></pre>