Last active
February 21, 2017 01:01
-
-
Save oznus/ceca5c7b617458fb53080ec5edc03d14 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 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