This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead
This is the error I got, I searched for solutions but I didn't find how to solve it. This is my code:
styles.xml
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/myPrimaryColor</item> <item name="colorPrimaryDark">@color/myPrimaryDarkColor</item> <item name="colorAccent">@color/myAccentColor</item> <item name="android:textColorPrimary">@color/myTextPrimaryColor</item> </style> <style name="ActionBarPopupThemeOverlay" parent="Theme.AppCompat.Light.NoActionBar"> <item name="windowActionBar">false</item> </style> <style name="Toolbartitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"> <item name="android:textColor">@android:color/white</item> </style> <style name="ToolbarSubtitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle"> <item name="android:textColor">#56FFFFFF</item> </style>
send_comment.xml(my activity layout)
SendComment.java
public class SendComment extends ActionBarActivity { private Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.send_comment); toolbar = (Toolbar) findViewById(R.id.my_toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); } }
What am I doing wrong?