ListeComAdapter.java :  » App » rue89android » com » rue89 » Android Open Source

Android Open Source » App » rue89android 
rue89android » com » rue89 » ListeComAdapter.java
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;
  }
  
  

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.