1

Here is my menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
tools:ignore="HardcodedText"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/general_settings"
    android:title="Settings" />

<item
    android:id="@+id/settings_alert"
    android:title="Profile List" />

<item
    android:id="@+id/settings_alarm"
    android:title="Alarm List" />

<item
    android:id="@+id/settings_apps"
    android:title="App List" />
</menu>

There is no android:background in menu. I want to be able to choose a menu option and have it show a different background color until the next choice is made.

I am able to use android:isCheckable=true, but then it shows checkboxes which I don't want.

I have also tried working with onPrepareOptionsMenu and onMenuOpened, but setBackgroundColor isn't a attribute.

John Smith
  • 3,493
  • 3
  • 25
  • 52
  • https://stackoverflow.com/a/36643105/12187548 – harun karaca Feb 15 '22 at 18:12
  • @harunkaraca No, that didn't work. Keep in mind I'm just wanting the active menu item background changed. Not the whole background. – John Smith Feb 19 '22 at 01:02
  • https://stackoverflow.com/a/31074133/12187548 – harun karaca Feb 21 '22 at 17:33
  • @harunkaraca This is not a Navigation drawer. It is Options Drop Down list. Thanks though for persisting. I've tried several other things now and still no joy. – John Smith Feb 22 '22 at 19:11
  • Never understood why this is so difficult, If I can create a menu why hide the styling of it in so many layers or theme changes? I should be able to do so in the menu. I am in the midst of trying to do so for Darkmode. Alass I have almost no solution yet except resort to PopupMenu – JPM Jan 18 '23 at 03:14

0 Answers0