java - Do not request Window.FEATURE_ACTION_BAR issue -


i'm trying build app without success.. tried several way nothing worked. exception is:

caused by: java.lang.illegalstateexception: activity has action bar supplied window decor. not request window.feature_action_bar , set windowactionbar false in theme use toolbar instead. 

my style.xml is:

<resources>      <style name="apptheme" parent="theme.appcompat.light">          <!-- theme customizations -->          <item name="colorprimary">@color/colorprimary</item>         <item name="colorprimarydark">@color/colorprimarydark</item>         <item name="coloraccent">@color/coloraccent</item>         <item name="android:windownotitle">true</item>         <item name="android:windowactionbar">false</item>          <item name="android:textcolorprimary">@color/ldrawer_color</item>         <item name="actionmenutextcolor">@color/ldrawer_color</item>         <item name="android:textcolorsecondary">@color/ldrawer_color</item>     </style>  </resources> 

and can see have declared

<item name="android:windownotitle">true</item> <item name="android:windowactionbar">false</item> 

this manifest.xml

 <application         android:allowbackup="true"         tools:replace="android:icon"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <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> 

and baseactivity use extend other activities

import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar;  public abstract class baseactivity extends appcompatactivity {      public toolbar toolbar;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(getlayoutresource());         toolbar = (toolbar) findviewbyid(r.id.toolbar);         if (toolbar != null) {             setsupportactionbar(toolbar);             getsupportactionbar().settitle(baseactivity.this.getresources().getstring(r.string.app_name));             //getsupportactionbar().setdisplayhomeasupenabled(true);         }     }      protected abstract int getlayoutresource();      protected void setactionbaricon(int iconres) {         toolbar.setnavigationicon(iconres);     }  } 

i don't know why crashes..the way start application without crash set parent on style.xml in theme.appcompat.light.noactionbar in way status bar transparent , not colored...

using theme.appcompat.light tells android want framework provide actionbar you. however, creating own actionbar (a toolbar), giving framework mixed signals want actionbar come from.

since using toolbar, want theme.appcompat.light.noactionbar.

the next step make sure toolbar styled correctly, seems running issues. style toolbar actionbar using colors defined theme, need provide theme so:

<android.support.v7.widget.toolbar     android:layout_height="wrap_content"     android:layout_width="match_parent"     android:minheight="?attr/actionbarsize"     app:theme="@style/themeoverlay.appcompat.actionbar" /> 

see "styling" section toolbar widget on this android developers blog post more information.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -