Skip to content

Instantly share code, notes, and snippets.

@ejcer
Created September 6, 2014 19:24
Show Gist options
  • Save ejcer/4e0de1989b465889133a to your computer and use it in GitHub Desktop.
Save ejcer/4e0de1989b465889133a to your computer and use it in GitHub Desktop.
package com.noteworthy;
import java.util.ArrayList;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class ContributorAdapter extends ArrayAdapter<Contributor> {
ArrayList<Contributor> contributors;
public ContributorAdapter(Context context, int calendarListItem, ArrayList<Contributor> contributors) {
super(context, calendarListItem, contributors);
this.contributors = contributors;
}
@Override
public Contributor getItem(int position) {
// TODO Auto-generated method stub
return contributors.get(position);
}
// @Override
// public int getCount(){
// Log.d("pls show", "go sendgrid");
// return 4;
// }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Contributor contributor = getItem(position);
Log.d("pos", position+"");
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.calendarlist_item, parent, false);
}
// Lookup view for data population
TextView cName = (TextView) convertView.findViewById(R.id.nameLine);
TextView cCon = (TextView) convertView.findViewById(R.id.ContributionLine);
ImageView cPic = (ImageView) convertView.findViewById(R.id.profilePicture);
// Populate the data into the template view using the data object
cName.setText(contributor.name);
cCon.setText(contributor.contributionClass);
cPic.setImageResource(contributor.pictureResource);
// Return the completed view to render on screen
return convertView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment