简体   繁体   English

测试应用时,Android应用标题栏没有显示?

[英]Android app title bar doesn't show when testing the app?

I'm creating an app, and when I build it and start it on my phone (a Sony Xperia Z1 with Android 4.4.4), the title bar doesn't show. 我正在创建一个应用程序,当我构建它并在我的手机上启动它(带有Android 4.4.4的Sony Xperia Z1)时,标题栏不会显示。 All activities is rendered without the title bar, like this: 所有活动都在没有标题栏的情况下呈现,如下所示:

在此输入图像描述

I'm using Android Studio, and in the editor, the title bar is visible. 我正在使用Android Studio,在编辑器中,标题栏可见。 It just don't work when the app is being ran. 它只是在运行应用程序时不起作用。

All help with this is appreciated! 所有帮助都表示赞赏!

Update to this answer. 更新到这个答案。 ActionBarActivity was deprecated as of version 22.1.0. 自版本22.1.0起,不推荐使用ActionBarActivity。 To achieve this same outcome, extend AppCompatActivity. 要实现同样的结果,请扩展AppCompatActivity。

ActionBarActivity API Class Reference ActionBarActivity API类参考

I just found the answer. 我刚刚找到了答案。 Each of my Activity classes extended Activity , and when changing that to ActionBarActivity , the action bar (called "title bar" by me) shows up. 我的每个Activity类都扩展了Activity ,当将其更改为ActionBarActivity ,操作栏(由我称为“标题栏”)显示出来。 I changed those values when I created the classes, because I "was sure" that in all my other projects, the classes extended just Activity , and not ActionBarActivity , but I "was sure wrong". 我在创建类时更改了这些值,因为我“确定”在所有其他项目中,类只扩展了Activity ,而不是ActionBarActivity ,但我“肯定是错的”。

Thanks everyone for your suggestions! 谢谢大家的建议!

我不在我的电脑上,因此我无法链接它,但请转到您的styles.xml并确保没有任何内容表示NoActionBar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM