Search code examples
androidnavigation-drawer

Implement checkbox in navigation drawer items


Is there a way to implement the checkbox selection in Navigation drawer


Solution

  • You can add a custom View in your Navigation menu item using app:actionLayout="@layout/[Your layour]"

    Example :

    <?xml version="1.0" encoding="utf-8"?>
    <menu
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    
        <!--Other menu here-->
    
        <item xmlns:app="http://schemas.android.com/apk/res-auto"
              android:id="@+id/sample_key"
              android:title="Custom item"
              app:actionLayout="@layout/sample_layout"
              app:showAsAction="always" />
    
    </menu>