带有 Window.FEATURE_CUSTOM_TITLE 的 ActivityGroup 抛出 RuntimeException

发布于 2024-10-07 09:22:43 字数 942 浏览 2 评论 0原文

我正在使用一个具有方向感知能力的 ActivityGroup。

当手机处于纵向模式时,应启动Activity A。 当处于横向模式时,Activity B 应该启动。

我在这两个活动中都有一个自定义标题,它是在相应的 onCreate 方法中调用的。

我将自定义标题的初始化称为如下:

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    customTitleBar = new CustomTitleBar(getWindow());
    Log.d(TAG, "onCreate called");

    setContentView(R.layout.layout_a);
    customTitleBar.init();
    ...
}

当我单独启动每个 Activity 时,这一切都会起作用。

但是,当尝试在 ActivityGroup 中启动它们时,我的应用程序因以下异常而崩溃:

java.lang.RuntimeException: Unable to resume activity {foo.bar.MyActivityGroup}:
java.lang.RuntimeException: Unable to start activity ComponentInfo{foo.bar.ActivityA}:
android.util.AndroidRuntimeException:
You cannot combine custom titles with other title features

我没有在 ActivityGroup 中使用任何标题功能。有人能帮我解决这个问题吗?

I'm working with an ActivityGroup which is orientation-aware.

When the phone is in portrait-mode Activity A should be started.
When in landscape-mode Activity B should be started.

I do have a custom title in both of these activities, that is called within the corresponding onCreate methods.

I call the initialisation of the custom title like this:

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    customTitleBar = new CustomTitleBar(getWindow());
    Log.d(TAG, "onCreate called");

    setContentView(R.layout.layout_a);
    customTitleBar.init();
    ...
}

And it all works when I'm launching each Activity on it's own.

But when trying to start them within the ActivityGroup, my app crashes with this exception:

java.lang.RuntimeException: Unable to resume activity {foo.bar.MyActivityGroup}:
java.lang.RuntimeException: Unable to start activity ComponentInfo{foo.bar.ActivityA}:
android.util.AndroidRuntimeException:
You cannot combine custom titles with other title features

I'm not using any title feature within the ActivityGroup. Is anyone able to help me with this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稀香 2024-10-14 09:22:43

似乎不可能创建一个包含自定义标题“活动”的 ActivityGroup 。创建一个 Decorator 并将 Activity 传递到此装饰器中可以解决该问题。

It seems impossible to create an ActivityGroup with custom titled Activities in it. Creating a Decorator and passing the Activity into this decorator solves the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文