读书人

Android学习札记-Android简单有效的闪

发布时间: 2012-08-26 16:48:06 作者: rapoo

Android学习笔记----Android简单有效的闪屏制作

    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        new Handler().postDelayed(new Runnable(){public void run() {                Intent mainIntent = new Intent(SplashActivity.this,MainActivity.class);                 SplashActivity.this.startActivity(mainIntent);                 SplashActivity.this.finish(); }}, 10000);    }

?

在API中对于Handler的postDelayed方法描述如下:

Android API 写道final boolean postDelayed(Runnable r, long delayMillis) Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.

?

将Runnable对象r在经过deleyMillis的时间后加入到消息队列,也就是讲过多久以后做什么事情就可以了。看起来很简单,有点类似于HTML里面的setTimeout和setInternal方法,使用也非常简单。

?

读书人网 >Android

热点推荐