@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
LayoutInflater mInflater = LayoutInflater.from(MainActivity.this);
convertView = mInflater.inflate(R.layout.item_news, null);
viewHolder.descView = (TextView) convertView.findViewById(R.id.tv_desc);
viewHolder.iv = (ImageView) convertView.findViewById(R.id.iv_icon);
viewHolder.titleView = (TextView) convertView.findViewById(R.id.tv_title);
viewHolder.typeView = (TextView) convertView.findViewById(R.id.tv_type);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
News news = allNews.get(position);
viewHolder.titleView.setText(news.getTitle());
viewHolder.typeView.setText(news.getType() == 1 ? "专题" : "跟帖");
viewHolder.descView.setText(news.getDesc());
String imageurl1 = news.getImageurl();
setImageView(viewHolder.iv, imageurl1);
return convertView;
}