Lavine
Lavine

Reputation: 11

Getting rid of the Action Bar

I have tried getting rid of the action bar but I keep getting this error

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

MainActivity.java

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);//I added this
    setContentView(R.layout.activity_main);

Manifest file

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar" >//Changed this

I am using the theme below

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

I have read many posts and tried them but the app keeps crashing. Plaese help.

Upvotes: 0

Views: 59

Answers (4)

Suman Dey
Suman Dey

Reputation: 66

Try this: In style.xml

<style name="AppTheme.NoTitleBar" parent="android:Theme.Light">
    <item name="android:windowNoTitle">true</item>

In manifest.xml

<activity
        android:name=".InitializationActivity"
        android:label="@string/app_name"
        android:noHistory="true"
        android:screenOrientation="sensorLandscape"
        android:theme="@style/AppTheme.NoTitleBar" >

Upvotes: 0

Anirudh Sharma
Anirudh Sharma

Reputation: 7974

Try like this

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

and you Theme like:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

Upvotes: 0

karan
karan

Reputation: 8853

add below code to your theme in styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>

Upvotes: 0

Thomas R.
Thomas R.

Reputation: 8073

You need to use another parent theme:

<style name="AppTheme" parent=Theme.AppCompat.Light.NoActionBar">

instead of "DarkActionBar".

Upvotes: 2

Related Questions