简体   繁体   English

Android如何更改应用程序标题

[英]Android How to change the application title

HI I need to change the application title as when i move to new tab. 我需要更改应用程序标题,就像我移动到新标签页时一样。

i tried to change the app_name with varying string in string.xml but that is not actual dynamic change that i want. 我试图在string.xml中使用不同的字符串更改app_name,但这不是我想要的实际动态更改。

is there any alternative way of doing this? 有没有其他方法可以做到这一点?

You can simply call the setTitle() function from within your Activity . 您只需在Activity调用setTitle()函数即可。 It takes either an int (resource ID) or a CharSequence as a parameter. 它采用int (资源ID)或CharSequence作为参数。

android:label in AndroidManifest.xml is using reference to @string/app_name for user readable application name (app name in applications list or name under icon on main screen if you add shoutcut) androidManifest.xml中的android:label使用@ string / app_name引用用户可读的应用程序名称(应用程序列表中的应用程序名称或主屏幕上的图标下的名称,如果你添加了shoutcut)

For changing Activity title you should use setTitle() of Activity class. 要更改活动标题,您应该使用Activity类的setTitle()。

then you have to set the custom title for your app. 然后你必须为你的应用程序设置自定义标题 check my post. 检查我的帖子。

You have to set a custom layout for your title. 您必须为标题设置自定义布局。 you can access the TextView object from that. 您可以从中访问TextView对象。

Edit: 编辑:

Accept Apologize. 接受道歉。 i didnt read the question propely. 我没有正确地阅读这个问题。

setTitle() method is enough. setTitle()方法就足够了。 My answer is about to customizing the title.that is color, text size and all. 我的答案是自定义标题。这是颜色,文字大小等等。

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

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