0

Am showing a pop up menu dialog programmatically when a button is clicked.

 ImageButton Btn = findViewById(R.id.Btn);
        Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupMenu menu = new PopupMenu(getApplicationContext(), v);
                menu.getMenu().add(Menu.NONE, 1, 1, "A");
                menu.getMenu().add(Menu.NONE, 2, 2, "B");
                menu.getMenu().add(Menu.NONE, 3, 3, "C. You were sent to heal...");
                menu.show();
            }
        });

Now, I want to style the pop up menu dialog and change the background color. This is what I used in my styles.xml

<item name="android:itemBackground">@color/darkBlue</item>

However, I don't get any changes in my output.

Ben Ajax
  • 668
  • 2
  • 13
  • 27

1 Answers1

0

Try changing the color in your apps theme. at the .xml -file

    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@android:color/darkBlue</item>
    </style>
DeadlyHigh
  • 94
  • 8