Android应用启动界面实现
jopen
11年前
public class SplashScreen extends Activity { protected boolean _active = true; protected int _splashTime = 5000; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.splash); @SuppressWarnings("unused") ImageView image = (ImageView) findViewById(R.id.bg_branco); Thread splashTread = new Thread() { @Override public void run() { try { int waited = 0; while(_active && (waited < _splashTime)) { sleep(100); if(_active) { waited += 100; } } } catch(InterruptedException e) { } finally { finish(); startActivity(new Intent(SplashScreen.this,NavegadorMultitokyActivity.class)); stop(); } } }; splashTread.start(); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { _active = false; } return true; } }
AndroidManifest.xml配置:
<activity android:name=".SplashScreen" android:icon="@drawable/ico_app" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>