title: Is there any way to improve performance of loading images from assets?
body: <p>I have a ListView with an ImageView in each row.</p>
  
  <p>I have a customAdapter that loads image for each row in getView function.</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  
      View row = convertView;
      if (row == null) {
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = inflater.inflate(R.layout.list_row, parent, false);
          ViewHolder viewHolder = new ViewHolder();
          viewHolder.listImage = (ImageView) row
                  .findViewById(R.id.list_image);
          viewHolder.title = (TextView) row.findViewById(R.id.title);
          viewHolder.description = (TextView) row
                  .findViewById(R.id.description);
          row.setTag(viewHolder);
  
      }
  
  
      ItemDescription des = getItemDescriptionFromFile(items.get(position)
              + "/description.txt");
      ViewHolder holder = (ViewHolder) row.getTag();
      holder.title.setText(des.title);
      holder.description.setText(des.description+(position)%5);
  
      holder.listImage.setImageBitmap(getBitmapFromAsset(items.get(position));
      return row;
  
  }
  
  private Bitmap getBitmapFromAsset(String strName) {
  
      InputStream istr = null;
      try {
          istr = assetManager.open(strName);
      } catch (IOException e) {
          e.printStackTrace();
      }
      Bitmap bitmap = BitmapFactory.decodeStream(istr);
      return bitmap;
  }
  </code></pre>
  
  <p>But I noticed that the scrolling of the list is not smooth enough.</p>
  
  <p>I googled my problem and this link seems to be the solution:
  <a href="http://developer.android.com/training/improving-layouts/smooth-scrolling.html" rel="nofollow">http://developer.android.com/training/improving-layouts/smooth-scrolling.html</a></p>
  
  <p>But there are some issues with this code:</p>
  
  <pre><code>new AsyncTask&lt;ViewHolder, Void, Bitmap&gt;() {
  private ViewHolder v;
  
  @Override
  protected Bitmap doInBackground(ViewHolder... params) {
      v = params[0];
      return mFakeImageLoader.getImage();
  }
  
  @Override
  protected void onPostExecute(Bitmap result) {
      super.onPostExecute(result);
      if (v.position == position) {
          // If this item hasn't been recycled already, hide the
          // progress and set and show the image
          v.progress.setVisibility(View.GONE);
          v.icon.setVisibility(View.VISIBLE);
          v.icon.setImageBitmap(result);
      }
  }
  }.execute(holder);
  </code></pre>
  
  <p>I cannot access to position inside the inner class AsyncTask because position is not final.</p>
  
  <p>Is there any way to access position?</p>
  
  <p>What is the best way to make my list scroll smoothly?</p>
  
  <p>Thanks in advance.</p>