Last active
January 19, 2016 05:39
-
-
Save ColeMurray/bc5d7c89c01aa0df6e8a to your computer and use it in GitHub Desktop.
Milestone 1 Impression Adapter
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
| public class ImpressionAdapter extends RecyclerView.Adapter<ProductViewHolder> { | |
| private List<String> mDataSet; | |
| public ImpressionAdapter(Activity activity, List<String> dataSet) { | |
| mDataSet = dataSet; | |
| } | |
| @Override | |
| public ProductViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | |
| View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.product_item_layout, viewGroup, false); | |
| return new ProductViewHolder(view); | |
| } | |
| @Override | |
| public void onBindViewHolder(ProductViewHolder productViewHolder, int position) { | |
| String title = mDataSet.get(position); | |
| //alternate view background color | |
| productViewHolder.itemView.setBackgroundResource(position % 2 == 0 ? android.R.color.white : android.R.color.darker_gray); | |
| productViewHolder.mTitleTextView.setText(title); | |
| } | |
| @Override | |
| public int getItemCount() { | |
| return mDataSet.size(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment