公共类 Splash 扩展 Activity {
媒体播放器我们的歌曲;
@Override
protected void onCreate(Bundle Samiloveschicken) {
// TODO Auto-generated method stub
super.onCreate(Samiloveschicken);
setContentView(R.layout.splashscreen);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
ourSong.start();
final Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}
finally{
Intent openMainActivity = new Intent(Splash.this, MainActivity.class);
Splash.this.startActivity(openMainActivity);
Splash.this.finish();
overridePendingTransition(R.anim.mainfadein, R.anim.splashfadeout);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
ourSong.release();
super.onPause();
finish();
}
}
我是初学者,我尝试过 onClickListener 和其他各种方法都无济于事。我似乎不知道把这个方法放在哪里。当触摸屏幕时,我能够中断睡眠(5000)。