java - Action Bar Background Not Changing -


i have went on android , followed instructions style action bar , not working. app keeps stopping. can see changed color briefly message shown. have note 2 4.4.2.. here

styles.`

<?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme"     parent="@android:style/theme.holo.light.darkactionbar">     <item name="android:actionbarstyle">@style/myactionbar</item> </style>  <!-- actionbar styles --> <style name="myactionbar"     parent="@android:style/widget.holo.light.actionbar.solid.inverse">     <item name="android:background">#f00</item> </style> </resources>` 

manifest

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="funnestgames.actionbar" >  <application     android:theme="@style/customactionbartheme"     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     >     <activity         android:name=".mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application>  </manifest> 

and logcat.

    5-29 20:35:33.541      838-838/funnestgames.actionbar e/androidruntime﹕ fatal exception: main process: funnestgames.actionbar, pid: 838 java.lang.runtimeexception: unable start activity     componentinfo{funnestgames.actionbar/funnestgames.actionbar.mainactivity}:     java.lang.illegalstateexception: need use theme.appcompat theme (or     descendant) activity.         @ android.app.activitythread.performlaunchactivity(activitythread.java:2413)         @ android.app.activitythread.handlelaunchactivity(activitythread.java:2471)         @ android.app.activitythread.access$900(activitythread.java:175)         @ android.app.activitythread$h.handlemessage(activitythread.java:1308)         @ android.os.handler.dispatchmessage(handler.java:102)         @ android.os.looper.loop(looper.java:146)         @ android.app.activitythread.main(activitythread.java:5602)         @ java.lang.reflect.method.invokenative(native method)         @ java.lang.reflect.method.invoke(method.java:515)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1283)  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1099)  @ dalvik.system.nativestart.main(native method) caused by: java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity.  @  android.support.v7.app.appcompatdelegateimplbase.oncreate(appcompatdelegateimplbase.java:122)  @ android.support.v7.app.appcompatdelegateimplv7.oncreate(appcompatdelegateimplv7.java:146)         @ android.support.v7.app.appcompatactivity.oncreate(appcompatactivity.java:59)  @ funnestgames.actionbar.mainactivity.oncreate(mainactivity.java:16)  @ android.app.activity.performcreate(activity.java:5451)  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1093)  @ android.app.activitythread.performlaunchactivity(activitythread.java:2377)              at android.app.activitythread.handlelaunchactivity(activitythread.java:2471)              @ android.app.activitythread.access$900(activitythread.java:175)              @ android.app.activitythread$h.handlemessage(activitythread.java:1308)              at android.os.handler.dispatchmessage(handler.java:102)              @ android.os.looper.loop(looper.java:146)              @ android.app.activitythread.main(activitythread.java:5602)              @ java.lang.reflect.method.invokenative(native method)              @ java.lang.reflect.method.invoke(method.java:515)              @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1283)              @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1099)              @ dalvik.system.nativestart.main(native method) 

you can change background color following mainactivity class

actionbar actionbar = getsupportactionbar(); actionbar.setbackgrounddrawable(new colordrawable(color.parsecolor("#c71585"))); 

or not give error if use following style actionbar

<style name="myactionbar" parent="theme.appcompat.light.darkactionbar"> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -