package com.bwie.adapter;
import java.util.List;
import com.bwie.test.R;
import com.bwie.vo.Data;
import com.lidroid.xutils.BitmapUtils;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class MyAdapter extends BaseAdapter {
private Context context;
private List<Data> list;
public MyAdapter(Context context, List<Data> 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) {
// TODO Auto-generated method stub
ViewHodler vh;
String imageurl = list.get(position).getIMAGEURL();
if(imageurl==null){
vh = new ViewHodler();
convertView = LayoutInflater.from(context).inflate(R.layout.listview_item, null);
vh.title1 = (TextView) convertView.findViewById(R.id.title1);
vh.fromname1 = (TextView) convertView.findViewById(R.id.fromname1);
vh.time1 = (TextView) convertView.findViewById(R.id.time1);
vh.title1.setText(list.get(position).getTITLE());
vh.fromname1.setText(list.get(position).getFROMNAME());
vh.time1.setText(list.get(position).getSHOWTIME());
}else{
vh = new ViewHodler();
convertView = LayoutInflater.from(context).inflate(R.layout.listview_item1, null);
vh.title2 = (TextView) convertView.findViewById(R.id.title2);
vh.fromname2 = (TextView) convertView.findViewById(R.id.fromname2);
vh.time2 = (TextView) convertView.findViewById(R.id.time2);
vh.image = (ImageView) convertView.findViewById(R.id.imageView);
vh.title2.setText(list.get(position).getTITLE());
vh.fromname2.setText(list.get(position).getFROMNAME());
vh.time2.setText(list.get(position).getSHOWTIME());
BitmapUtils utils = new BitmapUtils(context);
utils.display(vh.image, list.get(position).getIMAGEURL());
}
return convertView;
}
class ViewHodler{
TextView title1,title2,fromname1,fromname2,time1,time2;
ImageView image;
}
}