Reputation: 131
I am having an issue when I applied the toolbar into the app and it crashed when I try to run the app.
style.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
/>
Main.java
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Manifest.xml
<application android:name="com.example.app.AppController" android:label="@string/app_name" android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.AppCompat.Light">
Logcat:
This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar.
Upvotes: 0
Views: 962
Reputation: 11
In my code only I disabled the line : //setSupportActionBar(toolbar);
on main class
Upvotes: 1
Reputation: 8063
Your manifest is wrong, i.e. applying the theme for the application.
Change it to:
android:theme="@style/AppTheme"
Because currently you use a style WITH action bar.
Upvotes: 1