package com.rue89;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* Permet de crer une liste personalise partir d'un tableau de commentaires
*
*
*/
public class ListeComAdapter extends BaseAdapter {
private Context mContext;
private Commentaire mListeCom[] = null;
public ListeComAdapter(Context context) {
mListeCom = null;
mContext = context;
}
@Override
public int getCount() {
if (mListeCom != null)
return mListeCom.length;
else
return 0;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
CommentaireView comView;
if (convertView == null) {
comView = new CommentaireView(mContext, mListeCom[position]);
} else {
comView = (CommentaireView) convertView;
comView.setCommentaire(mListeCom[position]);
}
return comView;
}
public Commentaire getCommentaireSelectionne(int position) {
return mListeCom[position];
}
public Commentaire[] getListeCommentaire() {
return mListeCom;
}
public void setListeArticle(Commentaire[] coms) {
mListeCom = coms;
}
}
|