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
|
@Override
public View getView(int position, View convertView, ViewGroup parent){
// * Le paramètre "convertView" permet de recycler les élements
// * de notre liste. En effet, l'opération pour convertir un layout
// * XML en IHM standard est très couteuse pour la plateforme Android.
// * On nous propose ici de réutiliser des occurences créées qui ne sont
// * plus affichées. Donc si ce paramètre est "null" alors, il faut "inflater"
// * notre layout XML, sinon on le réutilise
FeedView fv;
if (convertView == null)
{
fv = new FeedView();
convertView = inflater.inflate(R.layout.feed_view, null);
fv.creator = (TextView)convertView.findViewById(R.id.creator);
fv.title = (TextView)convertView.findViewById(R.id.title);
fv.pubDate = (TextView)convertView.findViewById(R.id.pub_date);
fv.img=(ImageView)convertView.findViewById(R.id.img);
convertView.setTag(fv);
}
else
{
fv = (FeedView) convertView.getTag()
}
fv.creator.setText(feeds.get(position).getCreator());
fv.pubDate.setText(feeds.get(position).getPubDate());
fv.title.setText(feeds.get(position).getTitle());
BitmapTaBitmap = BitmapFactory.decodeFile(Ton chemin); // le chemin en fonction de la position :)
fv.img.setImageBitmap(TaBitmap); // ou fv.img.setImageResource (int resId) si c'est l'image est une ressource
return convertView;
} |
Partager