gpt4 book ai didi

具有多个 Activity 的 Android 应用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:37:50 26 4
gpt4 key购买 nike

我有一个非常简单的游戏,它只包含一个 Activity ,我想添加一个标题屏幕。

如果标题屏幕是另一个 Activity ,我需要对我的 list 文件进行哪些更改才能使标题屏幕先打开?

游戏 Activity 称为 Leeder,标题屏幕 Activity 称为 LeederTitleScreen

这是我当前的 list 文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nifong.leeder"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="Leeder"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

最佳答案

你所要做的就是改变:

<activity android:name="Leeder"

到:

<activity android:name="LeederTitleScreen"

如果您希望您的标题屏幕通过 startActivity() 启动游戏,您还需要在 list 中声明您的 Leeder Activity 。

编辑:是的,您需要 部分。它告诉系统您的 Activity 将响应哪些隐式 Intent 。所以在你的 list 中, Intent 过滤器告诉系统它将响应 android.intent.category.LAUNCHER Intent ,这是 Android 在启动应用程序时调度的内容(即它告诉 Android 开始应用程序启动时的 Activity)。

Here很好地概述了 Intent 和 Intent 过滤器。

关于具有多个 Activity 的 Android 应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2225738/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com