requestFeature用行动吧 [英] requestFeature with action bar

查看:253
本文介绍了requestFeature用行动吧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直在寻找在谷歌的API演示,动作条,他们有这种

So I was looking at google's api demos for action bars and they have this

// 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);

但是,当我试图加code中的最后一行 getWindow()requestFeature(Window.FEATURE_ACTION_BAR); 我的应用程序只是死在启动。那么什么是真的?

but when I tried to add the last line of code getWindow().requestFeature(Window.FEATURE_ACTION_BAR); My app just dies on start up. So what does it really do?

推荐答案

秘诀是callings.The requestfeature必须之前调用补什么的顺序。我这样做是在这个秩序和正常工作:

The secret is the order of the callings.The requestfeature must be called before fill nothing. I do it in this order and works fine:

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

这篇关于requestFeature用行动吧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆