打开res/values/strings.xml文件,内容如下所示:
<resources>
<string name="app_name">HelloWorld</string>
</resources>
可以看到,这里定义了一个应用程序的字符串,我们有以下两种方式来引用它。
下边举一个简单的例子来帮助你理解,打开AndroidManifest.xml文件,找到如下代码:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
</application>
其中HelloWorld项目的应用图标就是通过android:icon属性来指定的,应用的名称则是通过android:label属性指定的。
本文由博客一文多发平台 OpenWrite 发布!
联系客服