为什么我无法更改应用中每个屏幕的操作栏中的标签?(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
更多推荐
发布评论