package com.example.im002.contacts.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.im002.R;

public class ItemContactsAdapter extends BaseAdapter {
	private Context mActivity;
	private List<ContactsListbean> list;
	
	public ItemContactsAdapter(Context contactActivity,
			List<ContactsListbean> list) {
		super();
		this.mActivity = contactActivity;
		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) {
		ContactsListbean bean=list.get(position);
		View view=View.inflate(mActivity, R.layout.item_contacts, null);
		ImageView con_head=(ImageView) view.findViewById(R.id.img_item_img);
		TextView name= (TextView) view.findViewById(R.id.tv_item_name);
		con_head.setImageResource(bean.getIconResouce());
		name.setText(bean.getName());
		
		
		return view;
	}

}
