How to change the color of an ActionBar?

How can I change the color of an ActionBar? I performed this and it works, but not the way I want. it changes color only after the start of activity, so immediately after launching the application the original hatching color is displayed, and only after a second my custom color does not spread. Is there any other way to handle this? thanks in advance

.... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar; actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#879f38"))); ..... 
+4
source share
1 answer

Create topic:

 <style name="Theme.MyAppTheme" parent="@android:style/Theme.Holo"> <item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item> </style> <style name="Theme.MyAppTheme.ActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:background">#222222</item> </style> 
+14
source

All Articles