0

actionbarsherlockを使用して、アプリで分割アクションバーを作成しました。タイトルバーをカスタムタイトルバーに変更したい場合、次の例外が発生します。

    09-20 17:29:14.893: E/AndroidRuntime(332): FATAL EXCEPTION: main
09-20 17:29:14.893: E/AndroidRuntime(332): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.xmlparsing/com.androidhive.xmlparsing.Listofcategories}: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.os.Looper.loop(Looper.java:123)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread.main(ActivityThread.java:3683)
09-20 17:29:14.893: E/AndroidRuntime(332):  at java.lang.reflect.Method.invokeNative(Native Method)
09-20 17:29:14.893: E/AndroidRuntime(332):  at java.lang.reflect.Method.invoke(Method.java:507)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-20 17:29:14.893: E/AndroidRuntime(332):  at dalvik.system.NativeStart.main(Native Method)
09-20 17:29:14.893: E/AndroidRuntime(332): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:192)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2110)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2261)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1427)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:218)
09-20 17:29:14.893: E/AndroidRuntime(332):  at com.androidhive.xmlparsing.Listofcategories.onCreate(Listofcategories.java:106)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-20 17:29:14.893: E/AndroidRuntime(332):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-20 17:29:14.893: E/AndroidRuntime(332):  ... 11 more

私のコードスニペットは

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.maincategories);
    actionbar=getSupportActionBar();
     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
4

2 に答える 2

4

アクションバー sherlock を使用してカスタム タイトル バーを配置するには、次の手順を実行する必要があります。

View actionbar = LayoutInflater.from(this).inflate(R.layout.actionbar, null);
getSupportActionBar().setCustomView(actionbar);
getSupportActionBar().setDisplayShowCustomEnabled(true);
于 2012-09-20T08:04:34.453 に答える
0

Theme.Sherlockから継承しSherlock.__Theme、その代わりにから継承しandroid:Theme.NoTitleBarます。

 <style name="Theme.NoTitleBar">
     <item name="android:windowNoTitle">true</item>
 </style>

これはと競合しますrequestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

于 2012-09-20T08:05:11.317 に答える