0

I am having some colors from server which should apply dynamically to the option menu item background. I need not to change the action bar color. Only the menu list background color. I can see several answers. But none of them are not programmatically/dynamically.

I tried https://stackoverflow.com/a/5647743/7444772 and I have got an exception (A factory has already been set on this LayoutInflater). Other examples are static methods

Community
  • 1
  • 1
Kiran K Jolly
  • 21
  • 1
  • 4
  • 1
    http://stackoverflow.com/questions/19659637/how-to-change-the-background-color-of-action-bars-option-menu-in-android-4-2 – sivaBE35 Jan 20 '17 at 07:36
  • 1
    @siva35 its not a dynamic method. So please undo the down vote and give me answer if possible. The colors are getting from server. – Kiran K Jolly Jan 20 '17 at 07:41
  • hy @KiranKJolly I Didn't Do – sivaBE35 Jan 20 '17 at 07:45
  • http://stackoverflow.com/questions/2719173/change-background-color-of-android-menu – Jacob Jan 20 '17 at 07:46
  • 1
    Possible duplicate of [Android: customize application's menu (e.g background color)](http://stackoverflow.com/questions/1593529/android-customize-applications-menu-e-g-background-color) – Enigo Jan 20 '17 at 07:52
  • Possible duplicate of [How to change the background color of the options menu?](http://stackoverflow.com/questions/2944244/how-to-change-the-background-color-of-the-options-menu) – Jacob Jan 20 '17 at 08:28
  • **@ all** I tried http://stackoverflow.com/a/5647743/7444772 and I have got an exception (A factory has already been set on this LayoutInflater). Other examples are static methods. – Kiran K Jolly Jan 20 '17 at 09:25

1 Answers1

0

Add in Manifest

<activity
    android:name="com.alarm.main.MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppActionBarTheme" />

Create A theme in Style

<resources>
<style name="MyAppActionBarTheme" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item>
<item name="android:itemTextAppearance">@style/TextAppearance</item>
</style>

<!-- The: background color for Action Bar overflow menu -->
<style name="MyApp.PopupMenu"        parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#0b19ba</item></style>

  <!-- Popup Menu Text Color styles -->
  <style name="TextAppearance"         parent="android:style/TextAppearance.Holo.Widget.ActionBar.Menu"> 
 <item name="android:textColor">#ffffff</item>
</style>
Sunil Chaudhary
  • 1,221
  • 12
  • 25