错误:此活动已有窗口装饰

时间:2016-06-09 17:05:13

标签: java android xml

我已经查看了其他帖子的答案,但仍不确定我哪里出错了。每当我尝试开始活动时,我都会收到此错误。

样式xml

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

<style name="AppTheme.NoActionBar" parent = "Theme.AppCompat.NoActionBar">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

活动管理控制xml

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/Theme.AppCompat.NoActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_admin_control" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_input_add" />

AdminControl活动

public class AdminControl extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_admin_control);
        Toolbar b = (Toolbar) findViewById(R.id.toolbar);
        b.setTitle("Tournaments");
        getSupportActionBar().hide();
        setSupportActionBar(b);
    }

    public void createNewTournament(View v) {
        Intent newIntent = new Intent(this, TournamentCreator.class);
        startActivity(newIntent);
    }
}

Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.kaushikshivakumar.vexteamqueuing">

    <uses-permission android:name="android.permission.INTERNET" />

    <!-- To auto-complete the email text field in the login form with the user's emails -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <application
        android:name=".VEXQueuing"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Initial">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".AdminLogin"
            android:label="@string/title_activity_admin_login"
            android:parentActivityName=".Initial">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.myname.vexteamqueuing.Initial" />
        </activity>
        <activity android:name=".TournamentCreator" />
        <activity
            android:name=".AdminControl"
            android:label="@string/title_activity_admin_control"
            android:parentActivityName=".Initial"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.myname.vexteamqueuing.Initial" />
        </activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

您的AndroidManifest.xml似乎在应用标记中有android:theme="@style/AppTheme"。将其更改为android:theme="@style/AppTheme.NoActionBar"。并且

<android.support.design.widget.AppBarLayout
    //...
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar">

        <android.support.v7.widget.Toolbar
        //...
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.AppBarLayout>