我开始向splash.java添加声音,但是我得到了一个错误,我认为一切都很好,所以你可能会看到它并帮助我,我会非常好的
我得到的错误是:
Multiple markers at this line
- Syntax error on token ".", class expected after this token
- The method create(Context, Uri) in the type MediaPlayer is not applicable for the arguments (Splash,
就行了
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
我的节目是:
package com.sc.uploader;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle IloveU) {
// TODO Auto-generated method stub
super.onCreate(IloveU);
setContentView(R.layout.splash);
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
start.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally {
Intent openStarting = new Intent("com.sc.uploader.MAINACTIVITY");
startActivity(openStarting);
}
}
};
timer.start();
}
}
如果你能知道错误是什么以及如何修复它,我会非常感激。
答案 0 :(得分:0)
问题在于使用了错误的id
,因此应用程序对此处constructor
尝试使用的内容感到困惑。
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
不是正确的id
。相反,它需要
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.e);
由于Context, reaourceid
的语法似乎正确(使用constructor
),但应用尝试使用其他constructor
,这让我相信{{1}是不正确的......以防它可以帮助任何有类似问题的人。