package com.bwie.lenovo.yk1.adapter; import android.content.Context; import android.support.v4.app.FragmentActivity; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import com.bwie.lenovo.yk1.R; import com.bwie.lenovo.yk1.bean.COneBean; import com.nostra13.universalimageloader.core.ImageLoader; import java.util.List; public class CTwoAdapter extends BaseAdapter { private Context context; private List<COneBean.ResultsBean> resultsBeans; public CTwoAdapter(Context context, List<COneBean.ResultsBean> resultsBeans) { this.context = context; this.resultsBeans = resultsBeans; } @Override public int getCount() { return resultsBeans.size(); } @Override public COneBean.ResultsBean getItem(int position) { return resultsBeans.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder=null; if(convertView==null){ holder=new ViewHolder(); convertView=View.inflate(context, R.layout.channel_two_listitem2,null ); holder.ivImage=convertView.findViewById(R.id.tv_image); holder.tvText=convertView.findViewById(R.id.tv_text); convertView.setTag(holder); }else { holder= (ViewHolder) convertView.getTag(); } holder.tvText.setText(resultsBeans.get(position).getDesc()); if (resultsBeans.get(position).getImages()!=null){ ImageLoader.getInstance().displayImage(resultsBeans.get(position).getImages().get(0), holder.ivImage); } return convertView; } class ViewHolder{ ImageView ivImage; TextView tvText; } }