在 android 中命名我的应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2444040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Naming my application in android
提问by Sephy
I think I'm getting senile because I was convinced that to give a name to your application, you had to fill this part of the manifest:
我想我越来越老了,因为我确信要为您的应用程序命名,您必须填写清单的这一部分:
<application android:icon="@drawable/icon" android:label="MyApplicationName">
However for a reason I don't understand, my application gets the name of my first activity, in which I load data, thus, it is called "Loading", defined as follows in the manifest:
但是由于我不明白的原因,我的应用程序获取了我加载数据的第一个活动的名称,因此,它被称为“加载”,在清单中定义如下:
<activity android:name="AccueilSplash" android:label="Loading">
Any idea why that is?
知道这是为什么吗?
回答by yanchenko
The launcher actually shows android:label
and android:icon
for activity(ies) that declare
启动器实际显示android:label
和android:icon
声明的活动
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
so application label is of no use.
所以应用程序标签没有用。
回答by Re MiDa
It is an already known issue of the tool (I suppose you are using eclipse). Google Group - Android Developers.
这是该工具的一个已知问题(我想您正在使用 eclipse)。Google Group - Android 开发人员。
The Application and the first Activity share the same name specified in the android:label
field of the <activity>
item.
应用程序和第一个活动共享android:label
在<activity>
项目字段中指定的相同名称。
If you want to use different titles for the launcher in the app list and the first activity, you can choose between these options:
如果您想为应用列表中的启动器和第一个活动使用不同的标题,您可以在以下选项之间进行选择:
1.a) Set just the Application name in the Manifest.
1.a) 在清单中只设置应用程序名称。
<application
android:label="@string/app_name"
... >
and don't specify android:label="@string/title_first_activity"
for the first Activity. It will inherit the Application label.
并且不要android:label="@string/title_first_activity"
为第一个活动指定。它将继承 Application 标签。
OR
或者
1.b) Set the Application name in the android:label
field of the first Activity in the Manifest.
1.b)android:label
在清单中第一个活动的字段中设置应用程序名称。
<activity
android:label="@string/app_name"
... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The <application>
item will share the same label of the <activity>
item, whether you specify a value for the <application>
's android:label
field or not.
无论您是否为's字段指定值,该<application>
项目都将共享该项目的相同标签。<activity>
<application>
android:label
The next step is:
下一步是:
2) Set the title for the first Activity at run-time in the FirstActivity.class
2)在FirstActivity.class中设置运行时第一个Activity的标题
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
setTitle(R.string.title_activity_login);
//TODO: insert the rest of the code
}
In this way your first Activity will change his title few moments after it will be shown on the screen of your phone.
通过这种方式,您的第一个活动将在您的手机屏幕上显示后不久更改其标题。
回答by Matt Swanson
Are you referring to the title at the top of the screen when you run the application? If so, that title bar shows the label of the current activity I believe.
当您运行应用程序时,您指的是屏幕顶部的标题吗?如果是这样,该标题栏会显示我相信的当前活动的标签。