public class TaskAdapter extends BaseAdapter { private Context mContext; private ArrayList<TaskModel> taskModelList = new ArrayList<>(); public TaskAdapter(Context mContext, ArrayList<TaskModel> taskModelList) { this.mContext = mContext; this.taskModelList = taskModelList; } public class Holder { private ImageView img; private TextView title; private TextView intent; private TextView kind; private TextView location; private TextView name; private TextView money; private TextView num; } @Override public int getCount() { if (null == taskModelList) { return 0; } else { return taskModelList.size(); } } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { final Holder holder; if (null == convertView) { holder = new Holder(); convertView = LayoutInflater.from(mContext).inflate(R.layout.item_4_list_view_task, null); holder.img = (ImageView) convertView.findViewById(R.id.img_4_task_list); holder.name = (TextView) convertView.findViewById(R.id.tv_4_task_list_name); holder.title = (TextView) convertView.findViewById(R.id.tv_4_task_list_title); holder.intent = (TextView) convertView.findViewById(R.id.tv_4_task_list_intent); holder.kind = (TextView) convertView.findViewById(R.id.tv_4_task_list_kind); holder.location = (TextView) convertView.findViewById(R.id.tv_4_task_list_location); holder.money = (TextView) convertView.findViewById(R.id.tv_4_task_list_money); holder.num = (TextView) convertView.findViewById(R.id.tv_4_task_list_num); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } final TaskModel info = taskModelList.get(position); // ImgCacheUtil.getInstance().setImage(holder.img, info.getTaskImgURL().toString()); holder.name.setText(info.getTaskName()); holder.title.setText(info.getTaskTitle()); holder.intent.setText(info.getTaskIntent()); holder.kind.setText(info.getTaskKind()); holder.location.setText(info.getTaskLocation()); holder.money.setText(MoneyUtils.getFormatMoneyStr(info.getTaskMoney())); holder.num.setText(info.getTaskNum()); return convertView; } public void setAdapterData(ArrayList<TaskModel> data) { taskModelList.addAll(data); } }