Skip to content
Advertisement

How to user RecyclerView inside of NavigationDrawer

I want to use a RecyclerView inside of a NavigationDrawer but I’m not sure how to do it. This is what i want to do:

Image of the preferred Layout

I want to have a List inside the Navigation Drawer where you can add entries with a Button/Textfield and delete them by swiping. If there’s a better way to do this then with NavigationDrawer and RecyclerView, please let me know. The List will have a limited amound of entries, so Performance should not be an issue.

Here is what i’ve got so far:

MainActivity.java

JavaScript

RecyclerAdapter.java

JavaScript

activity_main.xml

JavaScript

nav_header.xml

JavaScript

row_item.xml

JavaScript

So far I get a NullPointerException: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.recyclerview.widget.RecyclerView.setLayoutManager(androidx.recyclerview.widget.RecyclerView$LayoutManager)' on a null object reference I’m pretty sure thats because of the LayoutInflater because the RecyclerView is not part of the main activity but i don’t know how to fix it.

Advertisement

Answer

Use below code for custom drawer with Recyclerview

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement