| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 
 |  
public class UsersListViewAdapter extends BaseAdapter {
	Context mContext;
	ArrayList<ComplexUser> mComplexUsersList;
	LayoutInflater inflater;
 
	public UsersListViewAdapter(Context context, ArrayList<ComplexUser> objects) {
		this.mContext = context;
		this.mComplexUsersList = objects;
		this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
 
	@Override
	public int getCount() {		
		return mComplexUsersList.size();
	}
 
	@Override
	public Object getItem(int position) {
		return mComplexUsersList.get(position);
	}
 
	@Override
	public long getItemId(int position) {
		return position;
	}
 
	public static class ViewHolder {
		TextView tvNom;
		TextView tvPrenom;
		TextView tvIdentifiant;
		TextView tvCode;
	}
 
	@Override
	public View getView(int pos, View inView, ViewGroup parent) {
		final ViewHolder holder;
 
        // Si la ligne n'éxiste pas, on créé la ligne 
        if (inView == null) {
           inView = this.inflater.inflate(R.layout.cursor_users_row, parent, false);
           holder = new ViewHolder();
           // On affecte les views
           holder.tvNom = (TextView) inView.findViewById(R.id.CursorUsersRow_TextView_Nom);
           holder.tvPrenom = (TextView) inView.findViewById(R.id.CursorUsersRow_TextView_Prenom);
           holder.tvIdentifiant = (TextView) inView.findViewById(R.id.CursorUsersRow_TextView_Identifiant);
           holder.tvCode = (TextView) inView.findViewById(R.id.CursorUsersRow_TextView_Code);
           inView.setTag(holder);
        }
        // Sinon on récupère la ligne qui est en mémoire
        else
        	holder = (ViewHolder) inView.getTag();
 
        // On récupère l'objet courant
        ComplexUser complexUser = this.mComplexUsersList.get(pos);
 
        // On met à jour nos views
        holder.tvNom.setText(complexUser.getNom());
        holder.tvPrenom.setText(complexUser.getPrenom());
        holder.tvIdentifiant.setText(complexUser.getIdentifiant());
        holder.tvCode.setText(complexUser.getCode());
 
        return (inView);
	}
 
	@Override
	public boolean isEnabled(int position) {
		return true;
	}
} | 
Partager