1 2 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 71 72 73 74 75 76 77 78
| package fr.binou.alphaloan.interfaces;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.QuickContactBadge;
import android.widget.TextView;
import fr.binou.alphaloan.R;
import fr.binou.alphaloan.modeles.FicheTransactions;
import fr.binou.alphaloan.modeles.Nature;
public class ListViewFiches extends ArrayAdapter<FicheTransactions>{
private LayoutInflater inflater;
public ListViewFiches(Context context, ArrayList<FicheTransactions> fiches){
super(context, R.layout.fiche_adapter, fiches);
inflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent){
LinearLayout layoutItem;
if(convertView ==null){
layoutItem = (LinearLayout) inflater.inflate(R.layout.fiche_adapter, parent, false);
}
else{
layoutItem = (LinearLayout) convertView;
}
QuickContactBadge photoContact = (QuickContactBadge) layoutItem.findViewById(R.id.photoContact);
TextView nomContact = (TextView) layoutItem.findViewById(R.id.nomContact);
TextView montantContact = (TextView) layoutItem.findViewById(R.id.montantContact);
FicheTransactions fiche = getItem(position);
photoContact.setImageResource(R.drawable.photodefaut);
nomContact.setText(fiche.getContact().getPseudo());
//Texte du montant
montantContact.setText(" " + String.valueOf(fiche.getMontant()) + "");
/*
//Couleur de la fleche
int couleurFleche;
if(fiche.getMontant() < 10)
couleurFleche = Color.parseColor("#00FF00");
else if(fiche.getMontant() < 20)
couleurFleche = Color.parseColor("#FF7F00");
else
couleurFleche = Color.parseColor("#FF0000");
*/
Drawable fleche;
if(fiche.getNature() == Nature.ENTRANT)
fleche = getContext().getResources().getDrawable(R.drawable.arrow_up);
else
fleche = getContext().getResources().getDrawable(R.drawable.arrow_down);
//fleche.setColorFilter(couleurFleche, Mode.MULTIPLY);
montantContact.setCompoundDrawables(fleche, null, null, null);
return layoutItem;
}
} |