私に似た質問の多くの回答を読んでいますが、まだ問題を解決するのに問題があります。AsyncTask クラスを使用してバックグラウンドで画像を読み込む RSS リーダーのプロジェクトがあります。プログラムは機能しますが、ユーザーがすばやくスクロールすると、画像が行に読み込まれないことがあります。間違った場所に読み込まれることはありません。ユーザーがすばやくスクロールすると、スキップされたように見えます。また、起動時に、ユーザーが表示できる 4 つの行のうち、リストビュー内の 2 つまたは 1 つの画像のみが読み込まれます。
問題が私が使用している WeakReference オブジェクトに関係していることは知っていますが、より良い方法で実装する方法がわかりません...
これは私の RssListAdapter で、私の Async クラスも含まれています。
public class RssListAdapter extends ArrayAdapter<JSONObject>
{
TextView textView;
ImageView imageView;
JSONObject jsonImageText;
ProgressDialog progressDialog;
Activity activity2;
View rowView;
public RssListAdapter(Activity activity, List<JSONObject> imageAndTexts)
{
    super(activity, 0, imageAndTexts);
    activity2 = activity;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    Activity activity = (Activity) getContext();
    LayoutInflater inflater = activity.getLayoutInflater();
    // Inflate the views from XML
    View rowView = (View) inflater
            .inflate(R.layout.image_text_layout, null);
    jsonImageText = getItem(position);
    // ////////////////////////////////////////////////////////////////////////////////////////////////////
    // The next section we update at runtime the text - as provided by the
    // JSON from our REST call
    // //////////////////////////////////////////////////////////////////////////////////////////////////
    textView = (TextView) rowView.findViewById(R.id.job_text);
    imageView = (ImageView) rowView.findViewById(R.id.feed_image);
    BitmapDownloaderTask task = new BitmapDownloaderTask();
    Spanned text;
    try
    {
        text = (Spanned) jsonImageText.get("text");
        textView.setText(text);
    }
    catch (JSONException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    task.execute();
    return rowView;
}
public class BitmapDownloaderTask extends AsyncTask<String, Void, Bitmap>
{
    private String url;
    private RssListAdapter adapter;
    private WeakReference<ImageView> imageViewReference = null;
    @Override
    // Actual download method, run in the task thread
    protected Bitmap doInBackground(String... params)
    {
        imageViewReference = new WeakReference<ImageView>(imageView);
        Bitmap img = null;
        try
        {
            if (jsonImageText.get("imageLink") != null)
            {
                System.out.println("XXXX Link found!");
                String url = (String) jsonImageText.get("imageLink");
                URL feedImage = new URL(url);
                HttpURLConnection conn = (HttpURLConnection) feedImage
                        .openConnection();
                InputStream is = conn.getInputStream();
                img = BitmapFactory.decodeStream(is);
            }
        }
        catch (MalformedURLException e)
        {
            // handle exception here - in case of invalid URL being parsed
            // from the RSS feed item
        }
        catch (IOException e)
        {
            // handle exception here - maybe no access to web
        }
        catch (JSONException e)
        {
            // textView.setText("JSON Exception");
        }
        return img;
    }
    @Override
    // Once the image is downloaded, associates it to the imageView
    protected void onPostExecute(Bitmap bitmap)
    {
        if (isCancelled())
        {
            bitmap = null;
        }
        if (imageViewReference != null)
        {
            ImageView imageView = imageViewReference.get();
            if (imageView != null)
            {
                imageView.setImageBitmap(bitmap);
            }
        }
    }
    @Override
    // Before images are loaded
    protected void onPreExecute()
    {
        if (imageViewReference == null)
        {
            imageView.setImageResource(R.drawable.stub);
        }
    }
}
}