ada
public class MyBaseAdapter extends BaseAdapter {
private Context context;
private List<Tweet> list;
public MyBaseAdapter(Context context, List<Tweet> list) {
super();
this.context = context;
this.list = list;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return list.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Hand hand = null;
if (convertView == null) {
convertView = View.inflate(context, R.layout.list_item, null);
hand=new Hand();
hand.imageView = (ImageView) convertView.findViewById(R.id.imageView);
hand.tv_author = (TextView) convertView.findViewById(R.id.tv_author);
hand.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
hand.imageView2=(ImageView) convertView.findViewById(R.id.imageView2);
convertView.setTag(hand);
} else {
hand = (Hand) convertView.getTag();
}
BitmapUtils utils=new BitmapUtils(context);
utils.display(hand.imageView, list.get(position).portrait);
hand.tv_author.setText(list.get(position).author);
hand.tv_title.setText(list.get(position).body);
if(!list.get(position).imgSmall.equals("")&&list.get(position).imgSmall!=null){
utils.display(hand.imageView2, list.get(position).imgSmall);
}else{
hand.imageView2.setVisibility(View.GONE);
}
return convertView;
}
class Hand {
ImageView imageView;
TextView tv_author;
TextView tv_title;
ImageView imageView2;
};
}

浙公网安备 33010602011771号