一个很简单的例子:程序启动界面
?
主要code:
package com.ssx.startload;
?
<br>import android.app.activity;<br>import android.content.intent;<br>import android.os.bundle;<br>import android.os.handler;<br>import android.os.message;<br>import android.view.window;<br>import android.view.windowmanager;
public class startloadactivity extends activity {<br>?/** called when the activity is first created. */<br>??public static final int continue = 0x108;<br>??public static final int update = 0x109;<br>??final handler handler = new handler() {<br>[email protected]<br>???public void handlemessage(message msg) {
????switch (msg.what) {<br>????case startloadactivity.continue:
?????intent it = new intent();<br>?????it.setclass(startloadactivity.this, mainactivity.class);<br>?????startactivity(it);<br>?????finish();<br>?????break;<br>????}<br>????super.handlemessage(msg);<br>???}
??};
[email protected]<br>??public void oncreate(bundle savedinstancestate) {<br>???super.oncreate(savedinstancestate);<br>???getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,<br>?????windowmanager.layoutparams.flag_fullscreen);<br>???requestwindowfeature(window.feature_no_title);<br>???setcontentview(r.layout.start_loading);<br>???//handler.sendemptymessage(startloadingactivity.continue);<br>??thread sleepthread = new thread() {<br>????public void run() {
?????try {<br>??????thread.sleep(5000);//设置启动欢迎界面时间<br>??????intent it = new intent();<br>??????it.setclass(startloadactivity.this, mainactivity.class);<br>??????startactivity(it);<br>??????handler.sendemptymessage(startloadactivity.continue);<br>?????} catch (interruptedexception e) {<br>??????// todo auto-generated catch block<br>??????e.printstacktrace();<br>??????handler.sendemptymessage(startloadactivity.continue);<br>?????}<br>????}<br>???};<br>???sleepthread.start();<br>??}<br>?}
?