Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This Activity already has an action bar supplied by the window decor. #48

Open
kierepka opened this issue Sep 21, 2015 · 5 comments
Open

Comments

@kierepka
Copy link

Error: java.lang.IllegalStateException: 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.

Code:

[Activity(Icon = "@drawable/icon", 
        ConfigurationChanges = AppConfig,
        Theme = CompatTheme)]
    public class MainActivity : AppCompatFormsApplicationActivity
    {
        const ConfigChanges AppConfig = ConfigChanges.Orientation | ConfigChanges.ScreenSize;
@kierepka
Copy link
Author

ps. Theme = "@style/Theme.AppCompat.NoActionBar") instead Theme = CompatTheme is working but without actionbar :(

@amccorma
Copy link

It seems to be this line causing it in:
AppCompatFormsApplicationActivity.cs

        if (this.Toolbar == null)
        {
            this.Toolbar = new Toolbar(this);
            this.AppCompatDelegate.SetSupportActionBar(this.Toolbar);
        }

If you comment this out, it works. not sure what happens removing this line, but the themes work.

this line:
this.AppCompatDelegate.SetSupportActionBar(this.Toolbar);

causes the error. Anyone know why?

@amccorma
Copy link

Is there a way to apply a theme besides NoActionBar keeping the Toolbar?

@kierepka
Copy link
Author

Hmm here on http://stackoverflow.com/questions/26515058/this-activity-already-has-an-action-bar-supplied-by-the-window-decor they are saying that we should use .NoActionBar theme. I try this solution, but without any luck (this same error). But It is working properly without this code ;)

@mikepham
Copy link
Contributor

I will take a look when I get a chance. I haven't had the time to try the 1.5 packages yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants