I\'ll use RecyclerView for a section header
I want to create section header when i insert each Date & Time data in SQLite Database
I followed
Create two different ViewHolder's and chnage them by condition like chatting recycler view like this example . in your case :
public int getItemViewType(int position) { UserMessage message = (UserMessage) mMessageList.get(position); if (message.getSender().getUserId().equals(SendBird.getCurrentUser().getUserId())) { // If the current user is the sender of the message return VIEW_TYPE_MESSAGE_SENT; } else { // If some other user sent the message return VIEW_TYPE_MESSAGE_RECEIVED; } }
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view; if (viewType == VIEW_TYPE_MESSAGE_SENT) { view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_message_sent, parent, false); return new SentMessageHolder(view); } else if (viewType == VIEW_TYPE_MESSAGE_RECEIVED) { view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_message_received, parent, false); return new ReceivedMessageHolder(view); } return null; }