Android應用啟動界面實現
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; } } </pre><br />
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>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!