android– 带动作栏的requestFeature

android– 带动作栏的requestFeature,第1张

概述所以我正在看谷歌的api演示动作栏,他们有这个//TheActionBarisawindowfeature.Thefeaturemustberequested//beforesettingacontentview.Normallythisissetautomatically//byyourActivity'sthemeinyourmanifest.Theprovidedsystem

所以我正在看谷歌的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);我的应用程序刚启动就死了.那真的是什么呢?

解决方法:

秘密是呼叫的顺序.必须在填充任何内容之前调用请求功能.我按此顺序执行并且工作正常:

getwindow().requestFeature(Window.FEATURE_ACTION_bar);super.onCreate(savedInstanceState);getSupportActionbar().hIDe();setContentVIEw(R.layout.your_activity_layout);
总结

以上是内存溢出为你收集整理的android – 带动作栏的requestFeature全部内容,希望文章能够帮你解决android – 带动作栏的requestFeature所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1116887.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存