gpt4 book ai didi

android - 带有操作栏的 requestFeature

转载 作者:太空宇宙 更新时间:2023-11-03 10:54:15 27 4
gpt4 key购买 nike

所以我在看谷歌的操作栏 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); 我的应用程序在启动时就死机了。那么它到底有什么作用呢?

最佳答案

secret 是调用的顺序。请求功能必须在什么都不填充之前调用。我按照这个顺序做并且工作正常:

getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.your_activity_layout);

关于android - 带有操作栏的 requestFeature,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8319664/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com