Created
August 28, 2015 13:30
-
-
Save survivingwithandroid/617da9977b85a51554a8 to your computer and use it in GitHub Desktop.
This file contains 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 ContactAdapter extends | |
RecyclerView.Adapter<ContactAdapter.ContactViewHolder> { | |
private List<ContactInfo> contactList; | |
public ContactAdapter(List<ContactInfo> contactList) { | |
this.contactList = contactList; | |
} | |
@Override | |
public int getItemCount() { | |
return contactList.size(); | |
} | |
@Override | |
public void onBindViewHolder(ContactViewHolder contactViewHolder, int i) { | |
ContactInfo ci = contactList.get(i); | |
contactViewHolder.vName.setText(ci.name); | |
contactViewHolder.vSurname.setText(ci.surname); | |
contactViewHolder.vEmail.setText(ci.email); | |
contactViewHolder.vTitle.setText(ci.name + " " + ci.surname); | |
} | |
@Override | |
public ContactViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | |
View itemView = LayoutInflater.from(viewGroup.getContext()). | |
inflate(R.layout.card_layout, viewGroup, false); | |
return new ContactViewHolder(itemView); | |
} | |
public static class ContactViewHolder extends RecyclerView.ViewHolder { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment