title: Slow performance in List View
body: <p>I'm having a really weird problem with my Android app. Simply put, the problem occurs when I put image content into a <code>ListView item</code>.
  For instance; let's say I have a <code>Fragment</code> with the following layout;</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;ListView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@android:id/list" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And the following layout for my 'list items';</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="50dp"&gt;
  
      &lt;ImageView
          android:layout_width="@dimen/list_image_width"
          android:layout_height="@dimen/list_image_height"
          android:id="@+id/listimage"
          android:scaleType="centerCrop" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/listtitle"
          android:layout_alignParentTop="true"
          android:layout_toRightOf="@+id/listimage"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:textSize="18sp"
          android:textColor="#000" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/listsubtitle"
          android:layout_below="@+id/listtitle"
          android:layout_alignRight="@+id/listtitle"
          android:layout_alignEnd="@+id/listtitle"
          android:textSize="17sp"
          android:textColor="#333"
          android:layout_alignBottom="@+id/listimage"
          android:layout_alignLeft="@+id/listtitle"
          android:layout_alignStart="@+id/listtitle" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This all goes well. The list presents itself just like the way I want it to. But, whenever I'm starting to put images (content) into the <code>ImageView</code>, things get messy. Whatever I do, the list loads horrendously slow and scrolling is near to impossible.
  I've tried multiple ways of loading images and putting them into the <code>ImageView</code>.
  Things I've tried:</p>
  
  <ul>
  <li>Using a <code>ViewHolder</code> in a custom <code>Adapter</code>, loading the Images in an <code>AsyncTask</code> from the <code>Drawables</code> folder and putting them into the <code>ImageView</code> on the <code>.onPostExecute()</code></li>
  <li>Using a <code>ViewHolder</code> in a custom <code>Adapter</code>, loading the images from the <code>Drawables</code> without using an <code>AsyncTask</code>.</li>
  <li>Using <a href="https://github.com/ribot/easy-adapter" rel="nofollow">EasyAdapter</a>, by loading the images from the <code>Drawables</code> on the <code>onSetValues()</code>.</li>
  <li>Using <a href="https://github.com/ribot/easy-adapter" rel="nofollow">EasyAdapter</a>, by loading the images from the <code>Assets</code> folder on `onSetValues()</li>
  </ul>
  
  <p>All of this didn't really do anything different but for the last option. The last option made the list more acceptable but still loading is really slow. (I press the button, the <code>fragment</code> gets initiated and I try to open it using the <code>TransactionManager</code>, this only seems to freeze the app for about 2-5 seconds before showing the list.) Scrolling is more acceptable as well, but still not as good as it could and <em>should</em> be. </p>
  
  <p>If I comment out the part where I <strong>set</strong> the Image into the <code>ImageView</code> and run it again there is absolutely nothing amiss with the view.
  What it all boils down to, is that setting the content from the Drawables folder is a no go. (although I've done this for every app I've built without problems). Setting the image content from the Assets folder improves performance immensely, but still not near the performance I'm expecting. Even when using the EasyAdapter as follows is giving a horrible UX:</p>
  
  <pre><code>@LayoutId(R.layout.list_default)
  public class ListAdapter extends ItemViewHolder&lt;Item&gt; {
  
      @ViewId(R.id.listimage)
      ImageView image;
  
      @ViewId(R.id.listtitle)
      TextView title;
  
      @ViewId(R.id.listsubtitle)
      TextView subtitle;
  
      public BeetListAdapter(View view) {
          super(view);
      }
  
      @Override
      public void onSetValues(BeetItem item, PositionInfo positionInfo) {
          title.setText(item.getTitle());
          subtitle.setText(item.getLatinname());
          image.setImageBitmap(getBitmapFromAsset(item.getFirstImageName()));
  
          getView().setTag(R.id.itemid, item.getId());
      }
  
      private Bitmap getBitmapFromAsset(String strName)
      {
          AssetManager assetManager = getContext().getAssets();
          InputStream istr = null;
          try {
              istr = assetManager.open("images/" + strName + ".jpg");
          } catch (IOException e) {
              e.printStackTrace();
          }
          Bitmap bitmap = BitmapFactory.decodeStream(istr);
          return bitmap;
      }
  
  }
  </code></pre>
  
  <p>Do you guys have ANY idea why this is? I'm not finding ANY reason nor a solution to why this is.
  Thanks in advance!</p>
  
  <p><strong>tl;dr</strong>: <em>My <code>ListView</code> is really slow when I put images into an <code>ImageView</code>. It doesn't seem to matter how and where they come from (ram, disk, internet). Whenever I do <code>imageView.setImageBitmap()</code> or <code>imageView.setDrawable()</code>, performance plummets and scrolling is nearly impossible.</em></p>