burakeregar / GenericRecyclerAdapter

Easiest way to use RecyclerView. Reduce boilerplate code! You don't need to write adapters for listing pages anymore!
MIT License
52 stars 19 forks source link

Multiple view type is not working. #2

Closed onlymnsh closed 7 years ago

onlymnsh commented 7 years ago

I Use this way to show multiple layout.

mAdapter = new GenericAdapterBuilder() .addModel( R.layout.contact_row, YourViewHolder.class, YourModel.class) .addModel( R.layout.second_row, YourSecondViewHolder.class, YourSecondModel.class) .addModel( R.layout.third_row, YourThirdViewHolder.class, YourThirdModel.class) .execute();

where i put condition which layout inflate at what position?

burakeregar commented 7 years ago

Hi,

You have to pass one list to the adapter. For instance, you have lists like below;

List<YourModel> yourList
List<YourSecondModel> yourSecondList
List<YourThirdModel> yourThirdList

You have to add all of them to an object list like below;

List<Object> yourObjectList

yourObjectList.addAll(yourList);
yourObjectList.addAll(yourSecondList);
yourObjectList.addAll(yourThirdList);

now you can pass your objectList to the adapter. Positioning depends on the objectlists' positions.

onlymnsh commented 7 years ago

Hi, Its working as u said. Could you please tell me how to switch to alternate viewtype and highlight the selected row like single selected item.

Thanks

burakeregar commented 7 years ago

All of those things just like the recyclerview. For highlighting the selected row; you can make itemview selected in your viewholder.

If you want to add new features besides above to the GenericRecyclerAdapter class, you can extend it or you can add some feature to this library and create a pull request.