android – How do I set an actionLayout on a title in a navigation drawer?-ThrowExceptions

Exception or error:

I have a Navigation Drawer, and a title set for a group of elements.

I can set the actionLayout on any of the other items and it works, but I can’t seem to workout how to set the action layout on the subgroup title.

Here is my code below,

<?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">
    <item android:title="Test1"  android:icon="@drawable/home_icon"/>
    <item android:title="Test2"  android:icon="@drawable/home_icon"/>
    <item android:title="Test3"  android:icon="@drawable/home_icon"/>
    <item android:title="Test4"  android:icon="@drawable/home_icon"/>
    <item android:title="Test5"  android:icon="@drawable/home_icon"/>
    <item android:title="Test Title" app:showAsAction="always" app:actionLayout="@layout/menu_image">
        <menu>
            <item android:title="Test6"  android:icon="@drawable/home_icon"/>
            <item android:title="Test7"  android:icon="@drawable/home_icon"/>
            <item android:title="Test8"  android:icon="@drawable/home_icon"/>
            <item android:title="Test9"  android:icon="@drawable/home_icon"/>
            <item android:title="Test10"  android:icon="@drawable/home_icon"/>
        </menu>
    </item>
</menu>

Below is an image of what I am trying to achieve – I can’t get the pink “change” button to show up on the toolbar title. It works on the other titles.

What I want it to look like with the change button.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *