请帮助当我运行我的应用程序时出现这些错误,我正在尝试制作一个 android 游戏
我已经尝试解决这个问题和其他问题超过 3 天
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zargoun.please"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.zargoun.please.Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
堆栈跟踪
D/AndroidRuntime(1115): Shutting down VM
W/dalvikvm(1115): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
E/AndroidRuntime(1115): FATAL EXCEPTION: main
E/AndroidRuntime(1115): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zargoun.please/com.zargoun.please.Main}: java.lang.ClassCastException: com.zargoun.please.Main cannot be cast to android.app.Activity
E/AndroidRuntime(1115): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
E/AndroidRuntime(1115): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(1115): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(1115): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(1115): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(1115): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(1115): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(1115): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1115): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(1115): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(1115): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(1115): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(1115): Caused by: java.lang.ClassCastException: com.zargoun.please.Main cannot be cast to android.app.Activity
E/AndroidRuntime(1115): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
E/AndroidRuntime(1115): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
E/AndroidRuntime(1115): ... 11 more
我得到错误:Activity 类型中的方法 setContentView(int) 不适用于参数(Maing)
public class Main extends Activity {
private Maing _game;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
_game = new Maing();
setContentView(_game);
}
}
这是从 libgdx 库中实现 Screen 的类 maing.java
import com.badlogic.gdx.Screen;
public class Maing implements Screen{
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void hide() {
// TODO Auto-generated method stub
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void render(float arg0) {
// TODO Auto-generated method stub
}
@Override
public void resize(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void show() {
// TODO Auto-generated method stub
}