带有 Window.FEATURE_CUSTOM_TITLE 的 ActivityGroup 抛出 RuntimeException
我正在使用一个具有方向感知能力的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎不可能创建一个包含自定义标题“活动”的
ActivityGroup
。创建一个Decorator
并将Activity
传递到此装饰器中可以解决该问题。It seems impossible to create an
ActivityGroup
with custom titled Activities in it. Creating aDecorator
and passing theActivity
into this decorator solves the issue.