How to create section header listing like whatsapp?

See this image

Put your header in your custom lisview adapter layout and check everytime your current message date and previous message date. If date is same then hide your header otherwise show your header. See below:

 holder.tvDate.setText(chatMessage.getDate());
    if (position > 0) {
        if (chatMessages.get(position).getDate().equalsIgnoreCase(chatMessages.get(position - 1).getDate())) {
            holder.header.setVisibility(View.GONE);
        } else {
            holder.header.setVisibility(View.VISIBLE);
        }
    } else {
        holder.header.setVisibility(View.VISIBLE);
    }