Reputation: 11
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
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
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
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
Reputation: 8073
You need to use another parent theme:
<style name="AppTheme" parent=Theme.AppCompat.Light.NoActionBar">
instead of "DarkActionBar".
Upvotes: 2