gpt4 book ai didi

java - 自定义主题您必须使用 Theme.Sherlock、Theme.Sherlock.Light、Theme.Sherlock.Light.DarkActionBar 或衍生产品

转载 作者:行者123 更新时间:2023-12-01 13:21:23 26 4
gpt4 key购买 nike

我正在使用自定义主题,代码如下:-

自定义样式.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#FFFFFF</item>

</style>

<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">40dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
<item name="android:windowBackground">@color/white</item>


</style>

Manifest.xml

  <application
android:name="com.exmaple.test.MainApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomTheme" >
<activity
android:name="com.exmaple.test.FirstActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>

菜单中心.java

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
@SuppressWarnings("deprecation")
LayoutParams layout = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
View cView = getLayoutInflater().inflate(R.layout.nav_bar_smart, null);
cView.setBackgroundColor(Color.parseColor(HeaderBackground));
actionBar.setCustomView(cView, layout);

输出有此错误:

02-25 10:14:15.645: E/AndroidRuntime(6542): FATAL EXCEPTION: main
02-25 10:14:15.645: E/AndroidRuntime(6542): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.MenuCenter}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread.access$500(ActivityThread.java:122)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.os.Handler.dispatchMessage(Handler.java:99)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.os.Looper.loop(Looper.java:132)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread.main(ActivityThread.java:4123)
02-25 10:14:15.645: E/AndroidRuntime(6542): at java.lang.reflect.Method.invokeNative(Native Method)
02-25 10:14:15.645: E/AndroidRuntime(6542): at java.lang.reflect.Method.invoke(Method.java:491)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
02-25 10:14:15.645: E/AndroidRuntime(6542): at dalvik.system.NativeStart.main(Native Method)
02-25 10:14:15.645: E/AndroidRuntime(6542): Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:855)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:267)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.slidingmenu.lib.app.SlidingFragmentActivity.setContentView(SlidingFragmentActivity.java:75)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.slidingmenu.lib.app.SlidingFragmentActivity.setContentView(SlidingFragmentActivity.java:67)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.slidingmenu.lib.app.SlidingFragmentActivity.setContentView(SlidingFragmentActivity.java:59)
02-25 10:14:15.645: E/AndroidRuntime(6542): at com.example.test.MenuCenter.onCreate(MenuCenter.java:70)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
02-25 10:14:15.645: E/AndroidRuntime(6542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)

最佳答案

替换

<style name="CustomTheme" parent="android:Theme">

<style name="CustomTheme" parent="Theme.Sherlock">

关于java - 自定义主题您必须使用 Theme.Sherlock、Theme.Sherlock.Light、Theme.Sherlock.Light.DarkActionBar 或衍生产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22003332/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com