嗨,我正在尝试学习延迟加载的概念。在我看到标题大纲的每个地方,但是它是如何实现的,找不到它遵循的模式。我从 github 的lazylist 项目中找到了以下代码。
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private String[] data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, String[] d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
TextView text=(TextView)vi.findViewById(R.id.text);;
ImageView image=(ImageView)vi.findViewById(R.id.image);
text.setText("item "+position);
imageLoader.DisplayImage(data[position], image);
return vi;
}
}
有人可以解释图像是如何延迟加载的..我正在尝试实现一个适配器,其中列表需要使用延迟加载..不确定如何实现。 http://pastebin.com/EPfMBRA1 这里我正在尝试用设备中的图像加载我的联系人任何帮助/建议表示赞赏。