欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Android应用闪屏(Splash)实例,androidsplash实例,public class

来源: javaer 分享于  点击 11880 次 点评:220

Android应用闪屏(Splash)实例,androidsplash实例,public class


public class SplashScreen extends Activity {    /**     * 处理闪屏(Splash)事件的线程     */    private Thread mSplashThread;        /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        // Splash screen view        setContentView(R.layout.splash);        final SplashScreen sPlashScreen = this;           // The thread to wait for splash screen events        mSplashThread =  new Thread(){            @Override            public void run(){                try {                    synchronized(this){                        // Wait given period of time or exit on touch                        wait(5000);                    }                }                catch(InterruptedException ex){                                    }                finish();                // Run next activity                Intent intent = new Intent();                intent.setClass(sPlashScreen, MainActivity.class);                startActivity(intent);                stop();                                }        };        mSplashThread.start();    }    /**     * 处理闪屏(Splash)触摸事件*/    @Override    public boolean onTouchEvent(MotionEvent evt)    {        if(evt.getAction() == MotionEvent.ACTION_DOWN)        {            synchronized(mSplashThread){                mSplashThread.notifyAll();            }        }        return true;    }}
相关栏目:

用户点评