好的,我知道我并不是接受率最高的人,我会弥补这一点。

我已经按照大量的启动画面教程和方法进行了思考,但是我发现有些东西会起作用...但是,声音却无法起作用...每当我完成操作时,我都会收到错误消息“无法解决或不是字段”

任何建议:这是COMPLETE SplashScreen.java代码:

 package com.droidnova.android;

 import android.app.Activity;
 import android.content.Intent;
 import android.media.MediaPlayer;
 import android.os.Bundle;
 import android.view.MotionEvent;
 import android.R;


 public class SplashScreen extends Activity {
protected boolean _active = true;
protected int _splashTime = 5000;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    MediaPlayer mpSplash = MediaPlayer.create(this, R.raw.laugh);
    mpSplash.start();

    // thread for displaying the SplashScreen
    Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                int waited = 0;
                while(_active && (waited < _splashTime)) {
                    sleep(100);
                    if(_active) {
                        waited += 100;
                    }
                }
            } catch(InterruptedException e) {
                // do nothing
            } finally {
                finish();
                startActivity(new Intent("com.droidnova.android.splashscreen.MyApp"));
                stop();
            }
        }
    };
    splashTread.start();
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        _active = false;
    }
    return true;
     }
}


有什么建议?

更新!

这是AndroidManifest.xml电影的代码:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.droidnova.android"
  android:versionCode="1"
  android:versionName="1.0">
 <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".SplashScreen"
              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=".MyApp">
        <intent-filter>
            <action android:name="com.droidnova.android.splashscreen.MyApp" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
 </application>
 <uses-sdk android:minSdkVersion="4" />
 </manifest>


第5行和第6行有错误:
第5行:error: Error: No resource found that matches the given name (at 'label' with value '@string/ app_name').
第6行:error: Error: No resource found that matches the given name (at 'label' with value '@string/ app_name').

添加了R.java:

 /* AUTO-GENERATED FILE.  DO NOT MODIFY.
  *
  * This class was automatically generated by the
  * aapt tool from the resource data it found.  It
  * should not be modified by hand.
  */

 package com.droidnova.android;

 public final class R {
     public static final class attr {
}
public static final class drawable {
    public static final int icon=0x7f020000;
}
public static final class id {
    public static final int textView1=0x7f050000;
}
public static final class layout {
    public static final int main=0x7f030000;
    public static final int splash=0x7f030001;
}
public static final class string {
    public static final int app_name=0x7f040000;
    public static final int main_screen=0x7f040001;
    public static final int splash_screen=0x7f040002;
}
}

最佳答案

尝试删除import android.R;

10-07 19:31
查看更多