Saturday, 26 March 2016

XML : Android TitleBar is still showing in design view even though I removed it in styles.xml

I am using activity and so I have to create my own toolbar and add it. Only problem is, the current default titlebar is not being removed even though I modified my styles.xml accordingly.

This is my file:

  <!-- Base application theme. -->  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">      <!-- Customize your theme here. -->      <item name="colorPrimary">@color/colorPrimary</item>      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>      <item name="colorAccent">@color/colorAccent</item>    </style>    

I have clearly stated "Theme.AppCompat.Light.NoActionBar"

I even tried this in one of my activity classes:

  public class ViewCars extends AppCompatActivity {       @Override          protected void onCreate(Bundle savedInstanceState) {              this.requestWindowFeature(Window.FEATURE_NO_TITLE);              super.onCreate(savedInstanceState);              setContentView(R.layout.carspage);          }  }    

And it crashes!

This is the actual error from the Android Studio:

  java.lang.RuntimeException: Unable to start activity ComponentInfo{benj.samplesapp/benj.samplesapp.ViewCars}: java.lang.IllegalStateException: 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 instead.                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)                                                                          at android.app.ActivityThread.access$600(ActivityThread.java:141)                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)                                                                          at android.os.Handler.dispatchMessage(Handler.java:99)                                                                          at android.os.Looper.loop(Looper.java:137)    

How do I remove the old one?

No comments:

Post a Comment