title: I wanna learn how to load images in Asynctask way and load those in listViewAdapter
body: <p>everybody,
  I get a problem that I use a listView to show hundreds of images from my local resources,and I set the image full of screen.There is a item with a imageView and a TextView in each list item.But when I slide to the next item ,it's not smoothly .I use the ImageFactory.options to adjust the scale of images.But the problem still exists.I guess maybe I should use asynctask loading and image cache to fix this problem.
  here is my code,hope you buddies point my problems.Thank you very much.</p>
  
  <pre><code>package com.jafir.project.adapter;
  
  
  import java.util.List;
  import java.util.Map;
  
  import com.jafir.project.porunacabeza.R;
  
  import android.content.Context;
  import android.content.res.Resources;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.Handler;
  import android.os.Message;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AbsListView.RecyclerListener;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class PicListViewAdapter extends BaseAdapter  {
      private Context context;
      private Resources resources;
      private LayoutInflater inflater;
      private ViewHolder holder;
      private List&lt;Map&lt;String, Object&gt;&gt; list;
      public PicListViewAdapter(Context context,List&lt;Map&lt;String, Object&gt;&gt; list) {
          this.list = list;
          this.context = context;
          this.inflater = LayoutInflater.from(context);
          resources = context.getResources();
      }
  
      @Override
      public int getCount() {
          return list.size();
      }
  
      @Override
      public Object getItem(int arg0) {
          return null;
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          if(convertView == null) {
               convertView = inflater.inflate(R.layout.item_pic, null);
              holder =  new ViewHolder();
              holder.imageView = (ImageView) convertView.findViewById(R.id.img_pic);
              holder.textView = (TextView) convertView.findViewById(R.id.txt_pic);
              convertView.setTag(holder);
  
          }else {
              holder = (ViewHolder) convertView.getTag();
          }
          int resID = (Integer) list.get(position).get("image");
          String text = (String) list.get(position).get("text");
          holder.imageView.setImageBitmap(decodeBitmap(resources, resID, holder.imageView.getWidth(),          holder.imageView.getHeight()));
          holder.textView.setText(text);
          notifyDataSetChanged();
          return convertView;
      }
  
      public Bitmap decodeBitmap(Resources res,int id,int width,int height){
          BitmapFactory.Options  options = new BitmapFactory.Options();
          options.inJustDecodeBounds = true;
          BitmapFactory.decodeResource(res,id,options);
          options.inSampleSize = getInSampleSize(options,width,height);
          options.inJustDecodeBounds = false;
          return BitmapFactory.decodeResource(res,id,options);
      }
  
      public int getInSampleSize(BitmapFactory.Options options,int reqWidth,int reqHeight){
          final int width  = options.outWidth;
          final int height = options.outHeight;
          int inSampleSize = 1;
          if(height &gt; reqHeight || width &gt; reqWidth) {
              int radioWidth = Math.round((float)width/(float)reqWidth);
              int radioHeight = Math.round((float)height/(float)reqHeight);
              inSampleSize = radioHeight &lt; radioWidth ?radioHeight:radioWidth;
          }
          return inSampleSize;
      }
  
        final static class ViewHolder{
              ImageView imageView;
              TextView textView;
          }
  }
  </code></pre>
  
  <p>this is for activity:</p>
  
  <pre><code> private void init() {
          listView = (ListView) getActivity().findViewById(R.id.lst_pic);
          list = new ArrayList&lt;Map&lt;String,Object&gt;&gt;();
          for(int i=0;i &lt; texts.length;i++){
              Map&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
              map.put("image", R.drawable.img0+ i);
              map.put("text", texts[i]);
              list.add(map);
          }
          listView.setAdapter(new PicListViewAdapter(getActivity(), list));
      }
  </code></pre>
  
  <p>this is for item.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:orientation="vertical"
   &gt;
  
      &lt;ImageView android:id="@+id/img_pic"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          /&gt;
      &lt;TextView android:id="@+id/txt_pic"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textSize="15dp"
          android:gravity="center_horizontal"
          android:layout_gravity="center_horizontal"
          /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>