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

Android实现ListView异步加载图片

 2010-06-19 18:23:00 来源:WEB开发网   
核心提示:import android.view.View;import android.widget.ImageView;import android.widget.TextView;public class ViewCache {private View baseView;private TextView textView;

import android.view.View;

import android.widget.ImageView;

import android.widget.TextView;

public class ViewCache {

private View baseView;

private TextView textView;

private ImageView imageView;

public ViewCache(View baseView) {

this.baseView = baseView;

}

public TextView getTextView() {

if (textView == null) {

textView = (TextView) baseView.findViewById(R.id.text);

}

return textView;

}

public ImageView getImageView() {

if (imageView == null) {

imageView = (ImageView) baseView.findViewById(R.id.image);

}

return imageView;

}

}

package cn.wangmeng.test;

import android.view.View;

import android.widget.ImageView;

import android.widget.TextView;

public class ViewCache {

private View baseView;

private TextView textView;

private ImageView imageView;

public ViewCache(View baseView) {

this.baseView = baseView;

}

public TextView getTextView() {

if (textView == null) {

textView = (TextView) baseView.findViewById(R.id.text);

}

return textView;

}

public ImageView getImageView() {

if (imageView == null) {

imageView = (ImageView) baseView.findViewById(R.id.image);

}

return imageView;

}

}

ViewCache是辅助获取adapter的子元素布局

Java代码

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;

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

Tags:Android 实现 ListView

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