带操作栏的 requestFeature

dom*_*yra 5 android android-actionbar

所以我正在查看 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);
Run Code Online (Sandbox Code Playgroud)

但是当我尝试添加最后一行代码时,getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 我的应用程序在启动时就死掉了。那么它到底有什么作用呢?

Esw*_*nti 0

我知道已经很晚了,你尝试过吗

requestWindowFeature(Window.FEATURE_ACTION_BAR)
Run Code Online (Sandbox Code Playgroud)