android recyclerview list item layout code example

Example 1: how to use mutliple layouts in recyclerview

@Override
public int getItemViewType(int position) {
        if(user_id_array.get(position).equals(user_one))
            return 1;
        else if(user_id_array.get(position).equals(user_two))
            return 2;
        else
            return 3;
}

Example 2: recyclerview layout oncreatw

@Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_listitem,parent,false);
        ViewHolder Holder = new ViewHolder(view);
        return Holder;
    }