score:242

Accepted answer

alternative to @sbaar's answer,

keep windowactionbar to false and add windownotitleas well and set it to true.

ie

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

score:0

i had the same problem when i upgraded the library version from 22.0.0 to 22.1.1 and fixed it by dropping back to the previous version: com.android.support:appcompat-v7:22.0.0 and go back to using actionbaractivity, not appcompatactivity in my activity classes as required by the newer version of the compatibility library. i'll try again later.

score:0

just use this in your style.xml no other editing is needed

 <style name="apptheme" parent="theme.appcompat">

<!-- theme customizations -->

<item name="colorprimary">@color/colorprimary</item>
<item name="colorprimarydark">@color/colorprimarydark</item>
<item name="coloraccent">@color/coloraccent</item>
</style>

don't add anything in to activity file please leave it

public class main extends actionbaractivity {

@override
protected void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_main);

 }

@override
public boolean oncreateoptionsmenu(menu menu) {
// inflate the menu; this adds items to the action bar if it is present.
getmenuinflater().inflate(r.menu.main, menu);
return true;
} 

@override
 public boolean onoptionsitemselected(menuitem item) {
// handle action bar item clicks here. the action bar will
// automatically handle clicks on the home/up button, so long
// as you specify a parent activity in androidmanifest.xml.
int id = item.getitemid();
if (id == r.id.action_settings) {
    return true;
}
return super.onoptionsitemselected(item);
}

 }

score:0

in java class change main extends actionbaractivity to main extends activity. it worked for me.

score:0

in my case, i look for @rewrihitesh answer, and i notice that i inverted elements order. changing from

setcontentview(r.layout.activity_test);
super.oncreate(savedinstancestate);

to

super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_test);

fix my problem.

hope it helps !!

score:1

add dependency to gradle like this

compile 'com.android.support:appcompat-v7:21.0.3'

score:1

i solved the issue by my main activity extending appcompatactivity :)

score:1

i had same issue somewhat, removed android: from my syles.xml as per below;

 <!-- caused crash -->
 <item name="android:windowactionbar">false</item>
 <item name="android:windownotitle">true</item>

 <!-- didn't cause crash -->
 <item name="windowactionbar">false</item>
 <item name="windownotitle">true</item>

score:2

if you have added <item name="windowactionbar">false</item>, then ,you need to add

<item name="windownotitle">true</item>

to solve the problem.

score:3

make sure that

super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_main);

are at the top of everything this works for me....good luck

score:3

in my case i didnt change to .noactionbar theme. i just remove android prefix from this item.

<item name="windowactionbar">false</item>

and the error goes away.

score:5

use this parent in style.xml parent="theme.appcompat.light.noactionbar"

score:16

check if you call setcontentview() after super.oncreate(), and not before. this helped in my case.

score:33

make sure that your theme is child from theme.appcompat.noactionbar, then in styles.xml:

<style name="mymaterialtheme" parent="theme.appcompat.noactionbar">
        <item name="windownotitle">true</item>
        ...
</style>

btw, it's a new issue for support library 22.1.

score:42

remove

<item name="windowactionbar">false</item>

from your theme, then make sure you are inheriting from a .noactionbar theme, then set your toolbar like normal.


Related Query

More Query from same tag