Created
September 6, 2014 17:46
-
-
Save ejcer/dfa8fc13a909424d379a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.noteworthy; | |
import java.util.ArrayList; | |
import android.content.Context; | |
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> { | |
public ContributorAdapter(Context context, ArrayList<Contributor> contributors) { | |
super(context, R.layout.calendarlist_item, contributors); | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
// Get the data item for this position | |
Contributor contributor = getItem(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