简体   繁体   English

Android动态标题栏

[英]Android dynamic title bar

I have one activity with 3 fragments, (top, center, bottom), and the top fragment it's like a title bar that I want to display different names and buttons, corresponding to the current screen. 我有一个包含3个片段的活动(顶部,中间,底部),顶部片段就像一个标题栏,我想显示不同的名称和按钮,对应于当前屏幕。 How can I implement this ? 我该如何实施呢?

Thanks, Pedro Simão 谢谢,佩德罗·西芒(PedroSimão)

The top bar that you are referring to as title bar is called an action bar in Android. 您称为标题栏的顶部栏在Android中称为操作栏。 You can do the following to change the text on this action bar as follows. 您可以执行以下操作来更改此操作栏上的文本,如下所示。

// Inside your activity
ActionBar ab = getActionBar();
ab.setTitle("My title");

You can then implement change the title according to whatever logic you'd like. 然后,您可以根据所需的逻辑实现更改标题。

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

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