【发布时间】:2015-02-20 07:21:37
【问题描述】:
所以我正在查看 google 的操作栏 api 演示,他们有这个
// The Action Bar is a window feature. The feature must be requested
// before setting a content view. Normally this is set automatically
// by your Activity's theme in your manifest. The provided system
// theme Theme.WithActionBar enables this for you. Use it as you would
// use Theme.NoTitleBar. You can add an Action Bar to your own themes
// by adding the element <item name="android:windowActionBar">true</item>
// to your style definition.
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
但是当我尝试添加最后一行代码getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 时,我的应用程序在启动时就死机了。那么它到底有什么作用呢?
【问题讨论】:
-
阅读您的日志猫并发布导致您的应用崩溃的异常的副本。
-
很可能,您说得太晚了。
requestFeature()需要在setContentView()之前调用。 -
@CommonsWare 是的,这就是它不起作用的原因。谢谢。这很奇怪,因为它只在模拟器中产生错误,而不是语法错误。