Android 当我使用setSupportActionBar()时,活动会刷新
我已经尝试将AppTheme windowActionBar设置为false,将应用程序的主题设置为我的自定义主题,以及AndroidManifest.xml文件中的活动,在toolbar.xml中设置主题,但没有任何效果 我的实际代码在哪里: 工具栏: 布局xml: 在style.xml中使用此选项 您已经扩展了Theme.AppCompat.NoActionBar主题。你不需要这条线Android 当我使用setSupportActionBar()时,活动会刷新,android,android-toolbar,Android,Android Toolbar,我已经尝试将AppTheme windowActionBar设置为false,将应用程序的主题设置为我的自定义主题,以及AndroidManifest.xml文件中的活动,在toolbar.xml中设置主题,但没有任何效果 我的实际代码在哪里: 工具栏: 布局xml: 在style.xml中使用此选项 您已经扩展了Theme.AppCompat.NoActionBar主题。你不需要这条线 如果您使用的是style-Theme.AppCompat.NoActionBar,则为false 删除上面的
如果您使用的是style-Theme.AppCompat.NoActionBar,则为false
删除上面的行并尝试运行它。它可以工作。检查您是否导入了正确的工具栏…同时显示您在类名上方定义的导入。请包括崩溃报告可能重复的
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
<style name="CustomTheme" parent = "Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<application>
<activity android:name=".home.Home">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_draw);
setTitle("Coffee Hour");
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
<include
android:id="@+id/tool_bar"
layout="@layout/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
<style name="MyTheme.NoActionBar">
<!-- Both of these are needed -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="CustomTheme" parent = "Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
setTitle("Coffee Hour");
setSupportActionBar(toolbar);