luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

Is it possible to change the itemResourceId layout #125

Closed alenux closed 6 years ago

alenux commented 6 years ago

Is it possible to change the itemResourceId layout at runtime ?

So you have two or more layout such as grid section and linear section ( gridview layout or list layout for item ).

In ItemViewHolder :

@Override
public RecyclerView.ViewHolder getItemViewHolder(View view) {
    return new ItemViewHolder(view);
}

but in recyclerview you can make

@NonNull

@Override
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
    View itemView;
    if (i == LIST_ITEM) {
        itemView = layoutInflater.inflate(R.layout.list_item, parent, false);
    } else {
        itemView = layoutInflater.inflate(R.layout.grid_item, parent, false);
    }
    return new CustomViewHolder (itemView);
}

or can you add methods in Section setItemViewHolder(/' new resource layout '/) setHeaderViewHolder(/' new resource layout '/) setFooterViewHolder(/' new resource layout '/)

Thanks in advance.

luizgrp commented 6 years ago

Please refer to #45