WEB开发网
开发学院手机开发Android 开发 Android实现ListView异步加载图片 阅读

Android实现ListView异步加载图片

 2010-06-19 18:23:00 来源:WEB开发网   
核心提示:}}});if (cachedImage == null) {imageView.setImageResource(R.drawable.default_image);}else{imageView.setImageDrawable(cachedImage);}// Set the text on the TextVi

}

}

});

if (cachedImage == null) {

imageView.setImageResource(R.drawable.default_image);

}else{

imageView.setImageDrawable(cachedImage);

}

// Set the text on the TextView

TextView textView = viewCache.getTextView();

textView.setText(imageAndText.getText());

return rowView;

}

}

package cn.wangmeng.test;

import java.util.List;

import cn.wangmeng.test.AsyncImageLoader.ImageCallback;

import android.app.Activity;

import android.graphics.drawable.Drawable;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.ArrayAdapter;

import android.widget.ImageView;

import android.widget.ListView;

import android.widget.TextView;

public class ImageAndTextListAdapter extends ArrayAdapter {

private ListView listView;

private AsyncImageLoader asyncImageLoader;

public ImageAndTextListAdapter(Activity activity, List imageAndTexts, ListView listView) {

super(activity, 0, imageAndTexts);

this.listView = listView;

asyncImageLoader = new AsyncImageLoader();

}

public View getView(int position, View convertView, ViewGroup parent) {

Activity activity = (Activity) getContext();

// Inflate the views from XML

View rowView = convertView;

ViewCache viewCache;

if (rowView == null) {

LayoutInflater inflater = activity.getLayoutInflater();

rowView = inflater.inflate(R.layout.image_and_text_row, null);

viewCache = new ViewCache(rowView);

rowView.setTag(viewCache);

} else {

上一页  1 2 3 4 5 6 7  下一页

Tags:Android 实现 ListView

编辑录入:coldstar [复制链接] [打 印]
赞助商链接