我正在使用本教程中的导航抽屉
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/ http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
我正在尝试更改此选定答案的操作栏背景
设置标题背景颜色 https://stackoverflow.com/questions/2251714/set-title-background-color
但是当我运行我的应用程序时,应用程序崩溃并显示错误
Manifest
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="info.androidhive.slidingmenu.MainActivity"
android:label="@string/app_name" >
</activity>
<activity android:name="Login_Page"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
>
</activity>
<activity android:name="Register"></activity>
<activity android:name="SplashActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
主要活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
LogCat
07-01 12:57:38.882:E / AndroidRuntime(14690):致命异常:主要
07-01 12:57:38.882: E/AndroidRuntime(14690):
java.lang.RuntimeException:无法启动活动
ComponentInfo{info.androidhive.slidingmenu/info.androidhive.slidingmenu.MainActivity}:
android.util.AndroidRuntimeException:您无法组合自定义标题
与其他标题功能 07-01 12:57:38.882: E/AndroidRuntime(14690):
在
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.app.ActivityThread.access$600(ActivityThread.java:128) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.os.Handler.dispatchMessage(Handler.java:99) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
android.os.Looper.loop(Looper.java:137) 07-01 12:57:38.882:
E/Android运行时(14690):位于
android.app.ActivityThread.main(ActivityThread.java:4517) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
java.lang.reflect.Method.invokeNative(原生方法) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
java.lang.reflect.Method.invoke(Method.java:511) 07-01 12:57:38.882:
E/Android运行时(14690):位于
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
dalvik.system.NativeStart.main(本机方法) 07-01 12:57:38.882:
E/AndroidRuntime(14690):原因:
android.util.AndroidRuntimeException:您无法组合自定义标题
与其他标题功能 07-01 12:57:38.882: E/AndroidRuntime(14690):
在
com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:245)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2701)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2921)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.app.Activity.setContentView(Activity.java:1835) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
info.androidhive.slidingmenu.MainActivity.onCreate(MainActivity.java:50)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.app.Activity.performCreate(Activity.java:4470) 07-01
12:57:38.882: E/AndroidRuntime(14690): 在
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-01 12:57:38.882: E/AndroidRuntime(14690): 在
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-01 12:57:38.882: E/AndroidRuntime(14690): ... 11 更多 07-01
12:57:38.892:E/AlarmManagerService(378):
android_server_AlarmManagerService_set 为 type=3, 51461.572000000
07-01 12:57:38.892: V/AlarmManager(378): waitForAlarm 结果:8 07-01
12:57:38.902: E/android.os.Debug(378): !@Dumpstate > dumpstate -k -t
-n -z -d -o /数据/日志/dumpstate_app_error
样式.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
<item name="android:textColor">@color/titletextcolor</item>
</style>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>