Skip to content

Instantly share code, notes, and snippets.

@oznus
Last active February 21, 2017 01:01
Show Gist options
  • Save oznus/ceca5c7b617458fb53080ec5edc03d14 to your computer and use it in GitHub Desktop.
Save oznus/ceca5c7b617458fb53080ec5edc03d14 to your computer and use it in GitHub Desktop.
public class ChatAdapter extends RecyclerView.Adapter<ItemViewHolder> {
private final Context context;
public ChatAdapter(Context context) {
this.context = context;
}
protected List<Item> items = new ArrayList<>();
@Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = (LayoutInflater)
this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return new ItemViewHolder(layoutInflater.inflate(R.layout.chat_message, parent, false));
}
@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
holder.bind(items.get(position));
}
@Override
public int getItemCount() {
return items.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment