1

I'm developing an android chat app. How can I make this info bar that indicates for example : "user left the group" or "user changed the group icon", like in the photo below:

YELLOW MARKS ScreenShot

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Muslem Omar
  • 1,021
  • 12
  • 12

1 Answers1

1
@Override
public int getItemViewType(int position) {
 final Chat chat = getItem(position);
    if (chat.getType() == LEFT_CHAT) {
        return ITEM_TYPE_LEFT_CHAT;
    } else if(chat.getType() == JOIN_CHAT){
        return ITEM_TYPE_JOIN_CHAT;
    } else if(chat.getType() == CHANGE_CHAT_ICON){
        return ITEM_TYPE_CHAGE_CHAT_ICON;
    } else {
        return ITEM_TYPE_NORMAL;
    }
}


@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    if (viewType == ITEM_TYPE_NORMAL) {
        View normalView = LayoutInflater.from(getContext()).inflate(R.layout.my_normal_row, null);
        return new MyNormalViewHolder(normalView); // view holder for normal items
    } else if (viewType == ITEM_TYPE_LEFT_CHAT) {
        View headerRow = LayoutInflater.from(getContext()).inflate(R.layout.left_chat_row, null);
        return new MyHeaderViewHolder(headerRow); // view holder for header items
    } else if (viewType == ITEM_TYPE_JOIN_CHAT) {
        View headerRow = LayoutInflater.from(getContext()).inflate(R.layout.join_chat_row, null);
        return new MyHeaderViewHolder(headerRow); // view holder for header items
    } else if (viewType == ITEM_TYPE_CHAGE_CHAT_ICON) {
        View headerRow = LayoutInflater.from(getContext()).inflate(R.layout.change_chat_icon_row, null);
        return new MyHeaderViewHolder(headerRow); // view holder for header items
    } 
}
Khaled Lela
  • 7,831
  • 6
  • 45
  • 73
  • That's what I excactly need. could you please share the full code with me or at least the layouts. THANK YOU SO MUCH – Muslem Omar Jul 23 '18 at 23:00