有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java应用程序在启动屏幕后崩溃(当菜单屏幕应该出现时)

我用菜单屏幕和闪屏做了一个游戏。我遵循了YouTube教程上的步骤。每次启动屏幕结束后(当菜单屏幕应该出现时),应用程序都会崩溃

这是我的代码,没有错误。问题出在哪里

启动屏幕:

package com.group5.littlered;

import 安卓.app.Activity;
import 安卓.content.Intent;
import 安卓.os.Bundle;
import 安卓.view.Window;
import 安卓.view.WindowManager;


public class MyMain extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

   //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.main|R.layout.splash); 
    setContentView(R.layout.splash);
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);
            } catch (InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent openStartingPoint = new Intent("com.group5.littlered.STARTINGPOINT");
                startActivity(openStartingPoint);               
                }   
        }
    };
    timer.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
  }
}

菜单屏幕:

package com.group5.littlered;

import 安卓.app.Activity;
import 安卓.os.Bundle;

public class MyMenu extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}}

安德里奥曼尼费斯特。xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.group5.littlered"
安卓:versionCode="1"
安卓:versionName="1.0" >

<uses-sdk
    安卓:minSdkVersion="8"
    安卓:targetSdkVersion="18" />

<application
    安卓:allowBackup="true"
    安卓:icon="@drawable/ic_launcher"
    安卓:label="@string/app_name"
    安卓:theme="@style/AppTheme" >
    <activity
        安卓:name=".MyMain"
        安卓:label="@string/app_name"
        安卓:screenOrientation="landscape"
        安卓:configChanges="keyboard|keyboardHidden|orientation" >
        <intent-filter>
            <action 安卓:name="安卓.intent.action.MAIN" />
            <category 安卓:name="安卓.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        安卓:name=".MyMenu"
        安卓:label="@string/app_name"
        安卓:screenOrientation="landscape"
        安卓:configChanges="keyboard|keyboardHidden|orientation" >
        <intent-filter>
            <action 安卓:name="com.group5.littlered.SPLASH" />
            <category 安卓:name="安卓.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

</application>


共 (0) 个答案