ShamylZakariya / StickyHeaders

Adapter and LayoutManager for Android RecyclerView which enables sticky header positioning.
MIT License
1.4k stars 185 forks source link

different view types #54

Open omrital opened 7 years ago

omrital commented 7 years ago

hi, is it possible to implement different types of view for item row ? i tried to do so according to the adapter functions but i found it not really possible. if there is a way please share thank you for your time !

RaviLalwani556 commented 7 years ago
 @Override
    public int getSectionItemUserType(int sectionIndex, int itemIndex) {
}

In this you will define which item type

@Override
    public ItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
        if (viewType == MESSAGE_TYPE_AUTHOR) {
            View view = LayoutInflater.from(context).inflate(R.layout.author_message_list_item, parent, false);
            return new MessageSectionedAdapter.AuthorViewHolder(view);
        } else if (viewType == MESSAGE_TYPE_RECIPIENT) {
            View view = LayoutInflater.from(context).inflate(R.layout.recipient_message_list_item, parent, false);
            return new MessageSectionedAdapter.RecipientViewHolder(view);
        }

        return null;
    }

Hope that help