为什么我无法更改应用中每个屏幕的操作栏中的标签?(Why can't I change the label in the action bar for each screen in my a

编程入门 行业动态 更新时间:2024-10-28 02:22:26
为什么我无法更改应用中每个屏幕的操作栏中的标签?(Why can't I change the label in the action bar for each screen in my app?)

我没有标签的2个活动的操作栏。 我希望主屏幕具有应用程序名称,并且下一个屏幕具有不同的标签。 这是我的清单文件:

<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:theme="@style/MSTheme" > <activity android:name="com.android.recipme.MainScreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.android.recipme.MyRecipes" android:label="@string/my_recipes" > </activity> </application>

我已经搜索了一些答案,似乎没有任何正确的答案。 请帮忙谢谢!

The action bar for the 2 activities I have don't have a label. I want the main screen to have the app name and the next screen to have a different label. Here is my manifest file:

<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:theme="@style/MSTheme" > <activity android:name="com.android.recipme.MainScreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.android.recipme.MyRecipes" android:label="@string/my_recipes" > </activity> </application>

I've searched for some answers and can't seem to get anything right. Please help thanks!

最满意答案

要更改所需活动的标题,包括以下行应该是您想要的,通常onCreate()是您要放置它的位置:

setTitle("SetYourTitle Here");

您可以参考此线程以获取更多信息: 如何更改操作栏上的文本

To change the title of the desired activity, including the following line should be what you want, usually onCreate( ) is where you'd want to put this:

setTitle("SetYourTitle Here");

You can refer to this thread for more information: How to change the text on the action bar

更多推荐

本文发布于:2023-08-01 14:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1360123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栏中   屏幕   标签   操作   change

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!