Please note: you do not have to create a new adapter every time you call onBindView (), you have to do it once in onCreateView ().
The best way is to use any library, for example - RendererRecyclerViewAdapter
How to add NestedRecyclerView:
Step 1: Add ViewModel to your Modal_Product_List
public class Modal_Product_List implements ViewModel { String getMedicinename() { ... }
Step 2: Create a ViewBinder for Modal_Product_List :
private ViewRenderer getModalProductViewRenderer() { return new ViewBinder<>( R.layout.item_row_medicine_productlist,
Step 3: Add the CompositeViewModel interface to PrescriptionModal or from DefaultCompositeModel :
public class PrescriptionModal extends DefaultCompositeViewModel { String getPrescriptionID() {...}
Step 4: Create a ViewBinder for PrescriptionModal :
private ViewRenderer getModalProductViewRenderer() { return new CompositeViewBinder<>( R.layout.item_row_digitised_request,
Step 5 (optional): If you need a custom LayoutManager , then extend the CompositeViewBinder and override the createLayoutManager method and use it instead of the CompositeViewBinder
public class CustomCompositeViewBinder extends CompositeViewBinder {
Step 6: Initialize the RendererRecyclerViewAdapter and the registration handler:
RendererRecyclerViewAdapter adapter = new RendererRecyclerViewAdapter(getContext()); recyclerView.setAdapter(adapter); adapter.registerRenderer(getModalProductViewRenderer()); adapter.registerRenderer(...);
This is a very short and easy way to add a Nested RecyclerView.
Vitaly Jan 26 '18 at 16:01 2018-01-26 16:01
source share