(一些代码可以让您了解我的代码)
HomeActivity.Java :(我的教程)
package com.wglxy.example.dash1;
import android.os.Bundle;
public class HomeActivity extends DashboardActivity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
}
protected void onDestroy ()
{
super.onDestroy ();
}
protected void onPause ()
{
super.onPause ();
}
protected void onRestart ()
{
super.onRestart ();
}
protected void onResume ()
{
super.onResume ();
}
protected void onStart ()
{
super.onStart ();
}
protected void onStop ()
{
super.onStop ();
}
} // end class
ChuchApplication.java(游戏应用程序):
/**
*
*/
package com.wglxy.example.dash1;
//import com.tmm.android.chuck.quiz.GamePlay;
import android.app.Application;
/**
* @author rob
*
*/
public class ChuckApplication extends Application{
private GamePlay currentGame;
/**
* @param currentGame the currentGame to set
*/
public void setCurrentGame(GamePlay currentGame) {
this.currentGame = currentGame;
}
/**
* @return the currentGame
*/
public GamePlay getCurrentGame() {
return currentGame;
}
}
这是我的androidmanifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wglxy.example.dash1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:icon="@drawable/sajda"
android:label="@string/app_name"
android:theme="@style/Theme.D1" >
<activity
android:name=".HomeActivity"
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=".F1Activity"
android:label="@string/title_feature1"
android:theme="@style/Theme.D1" />
<!--
activity
android:name=".F2Activity"
android:label="@string/title_feature2"
android:theme="@style/Theme.D1" />
-->
<activity
android:name=".F3Activity"
android:label="@string/title_feature3"
android:theme="@style/Theme.D1" />
<activity
android:name=".F4Activity"
android:label="@string/title_feature4"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial2"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial3"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial4"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial5"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<activity
android:name=".BasicTutorial6"
android:label="@string/title_feature5"
android:theme="@style/Theme.D1" />
<!-- activity
android:name=".SingleListItem"
android:label="Single Item Selected" >
</activity>-->
<service
android:name=".ChuckApplication"
android:theme="@style/Theme.D1" />
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:theme="@style/Theme.D1" />
<activity
android:name=".QuestionActivity"
android:theme="@style/Theme.D1" />
<activity
android:name=".RulesActivity"
android:theme="@style/Theme.D1" />
<activity
android:name=".EndgameActivity"
android:theme="@style/Theme.D1" />
<activity
android:name=".SettingsActivity"
android:theme="@style/Theme.D1" />
<activity
android:name=".AnswersActivity"
android:theme="@style/Theme.D1" />
</application>
</manifest>
谁能帮助我做什么?
任何困惑请评论我,我会尽力帮助你。
答案 0 :(得分:1)
有两个approch:
1)您可以将游戏项目作为一个库,通过意图,您可以调用游戏项目主要活动,但在您的主项目清单文件中定义游戏项目主要活动。
2)你可以在家庭项目中为游戏项目创建一个新的包,并将游戏项目的所有类和相关文件复制到该包中。记住你在布局文件夹和所有游戏项目中复制游戏项目的所有xml文件活动在您的主项目清单文件中声明。