I am trying to customize the secondary drawer using a separate class. But I am experiencing a crash. Please refer to the crash log attached below. Please help if possible
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.samsung.android.spaytouch.debug, PID: 11474
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
at com.mikepenz.materialdrawer.model.PrimaryDrawerItem.bindView(PrimaryDrawerItem.java:78)
at com.mikepenz.materialdrawer.model.PrimaryDrawerItem.bindView(PrimaryDrawerItem.java:18)
at com.mikepenz.fastadapter.FastAdapter$OnBindViewHolderListenerImpl.onBindViewHolder(FastAdapter.java:1662)
at com.mikepenz.fastadapter.FastAdapter.onBindViewHolder(FastAdapter.java:496)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4194)
at android.view.View.layout(View.java:22406)
@DarrelAeturnum if you modify the layout then ensure that all views and all ids are still present.
Otherwise follow the instructions on how to implement a custom drawerItem.
There is no really need to overwrite a layout for the provided items. Just implement a full custom item.
An item just requires to implement the IDrawerItem interface
Thanks @mikepenz. Can you provide a sample or step guide to implement a custom drawer item?, I actually created a custom PrimaryDrawerItem class by extending BasePrimaryDrawerItem class. But I am having issues in creating the custom SecondaryDrawerItem class.
@DarrelAeturnum you can actually do the same, the SecondaryDrawerItem only differs by the layout height being a bit different:
vs
It worked. Thanks @mikepenz . Is it possible to align the secondary options to align to the bottom of the screen ?
All items can be added as usual as sticky footer item: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.kt#L784