This error occurs when you try to use both the default action bar and a Toolbar in an Activity. To fix this, you need to set the windowActionBar attribute to false in your Activity's theme. Here's how you can do it:

  1. Open your app's styles.xml file.
  2. Locate the theme that you're using for your Activity.
  3. Add the following attribute to the theme:
<item name="windowActionBar">false</item>
  1. Save the file and rebuild your app.

By setting windowActionBar to false, you're telling Android to not provide a default action bar for your Activity. Instead, you can use a Toolbar widget to create your own custom action bar. Make sure that you remove any calls to getSupportActionBar() or getActionBar() in your Activity's code, as they will no longer work after you set windowActionBar to false

javalangIllegalStateException This Activity already has an action bar supplied by the window decor Do not request WindowFEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use

原文地址: https://www.cveoy.top/t/topic/epuT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录