简体   繁体   English

Android Change App图标标题

[英]Android Change App Icon Title

I have a single activity controlling many fragments. 我有一个活动可以控制许多片段。 When i perform certain fragment transactions I add the transaction to the back stack and enable the app icon in the action bar to navigate up, ie, setDisplayHomeAsUpEnabled(true) . 当我执行某些片段事务时,我将事务添加到后台堆栈,并在操作栏中启用应用程序图标向上导航,即setDisplayHomeAsUpEnabled(true) However, I'd like to change the text alongside the app icon (currently defaulting to the app name) at run time to provide the user with a better indication of where they are located in the app. 但是,我想在运行时更改应用程序图标旁边的文本(当前默认为应用程序名称),以便为用户提供关于他们在应用程序中位置的更好指示。 Any ideas of how this can be done? 关于如何做到这一点的任何想法?

Two ways, dynamically: 动态的两种方式:

ActionBar bar = getActionBar();
bar.setTitle("Title");
bar.setSubtitle("subtitle"); 

In manifest.xml: 在manifest.xml中:

 <application
    android:label="@string/app_name" >  

In Fragment: 在片段中:

(FragmentActivity) getActivity()).getActionBar().setTitle(R.string.title);

There is a lot of answers on that, try to do some researches to take these tricks, see: Handling ActionBar title with the fragment back stack? 对此有很多答案,请尝试做一些研究以获取这些技巧,请参阅: 使用片段返回堆栈处理ActionBar标题?

Use 采用

setTitle("title text")

...within an Activity to change the text shown in the title bar next to the icon. ...在“活动”中更改图标旁边标题栏中显示的文本。

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

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