在Android App中启动画面 [英] Splash Screen in android App
本文介绍了在Android App中启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package com.paad;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.ImageView;
public class Splash extends Activity {
/**
* The thread to process splash screen events
*/
private Thread mSplashThread;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Splash screen view
// The thread to wait for splash screen events
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
setContentView(R.layout.splash);
// Wait given period of time or exit on touch
wait(5000);
}
}
catch(InterruptedException ex){
}
finish();
// Run next activity
Intent intent = new Intent();
intent.setClass(Splash.this, main.class);
startActivity(intent);
stop();
}
};
mSplashThread.start();
}
/**
* Processes splash screen touch events
*/
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}
我在启动屏幕上有此代码,但未显示任何内容,它直接用于其他活动.
I have this code for my splash screen but nothing is shown and it directly intents to the other activity.
Please help with this problem?
推荐答案
此代码看起来像是从 ^ ]如果我犯了一个错误并且您的代码不是从那里获取的,为什么不看一下这篇文章,看看它是否可以帮助您更正代码.
/Darren
This code looks like it''s been taken from An Advanced Splash Screen for Android App[^] If I''ve made a mistake and your code is not taken from there, why not look at the article and see if it helps you correct your code.
/Darren
这篇关于在Android App中启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文