首页 文章

在应用程序标签中设置应用程序名称不起作用[重复]

提问于
浏览
9

这个问题在这里已有答案:

所以我有一个带有生成的登录屏幕的Android应用程序(你可以直接从Eclipse创建的) . 那很有效 . 问题是:我已将登录屏幕设置为Launcher活动 . 这有效 . 不幸的是,App被称为登录活动的标签参数 . 这意味着简单地忽略了应用程序的android:label值 .

这是我的代码,因为我的问题听起来很模糊:

<application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"  <!-- the app name i want it to have -->
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.test.testytest.MainActivity"
                android:configChanges="orientation"
                android:label="@string/app_name" >

            </activity>

<!-- some more activities -->

            <activity
                android:name="com.test.testytest.LoginActivity"
                android:label="@string/title_activity_login" <!-- the name the app is called in the drawer etc. -->
                android:windowSoftInputMode="adjustResize|stateVisible" >
                <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            </activity>
    </application>

strings.xml中:

<string name="app_name">Testy Test!</string>

strings_activity_login:

<string name="title_activity_login">Sign in</string>

当我将Login活动的字符串更改为app_name时,应用程序的名称也会更改 . 但我很确定应该按照android:label in中的定义来调用应用程序

希望你能帮助我或指出我的错误(也许我只是错过了一些细节) .

一点编辑:我不想更改我的登录活动的标签,因为它应该保持“登录” . 它也应该保持第一个被调用的活动 . 但抽屉中的App Name应该是定义的 .

1 回答

  • 6

    感谢Geobits:

    这是解决方案How to set different label for launcher rather than activity title?

    找到解决方案!显然,“intent-filter”可以具有label属性 . 如果不存在,则标签继承自父组件(活动或应用程序) . 因此,使用此功能,您可以为启动器图标设置标签,同时仍然拥有带有自己 Headers 的活动 . http://developer.android.com/guide/topics/manifest/intent-filter-element.html android:label =“@ string / title_home_activity”android:icon =“@ drawable / icon”>

相关问题