2011-06-27 15 views
9

アプリケーションが起動してメニューが表示されるまでに数秒間ロゴを表示したい。私はそれが消えたときにいくつかを使用したい。私は新しい活動を創り出すべきですか?私はレイアウトでそれを設定できますか?アプリケーション起動時に数秒間ロゴを表示する

+0

これはあなたを助けるかもしれません:http://www.barebonescoder.com/2010/04/a-simple-android-splash-screen/ –

+0

スプラッシュスクリーンのように? [Here](http://www.droidnova.com/how-to-create-a-splash-screen,561.html)はその一例です。 –

+0

また、http://www.gadgetsaint.com/android/create-video-splash-screen-android/をチェックしてください。 – ASP

答えて

15

あなたのロゴを含むスプラッシュ画面のレイアウトを定義してから、 ctivity:

public void onCreate(Bundle savedInstanceState){ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash); 
    //display the logo during 5 seconds, 
    new CountDownTimer(5000,1000){ 
     @Override 
     public void onTick(long millisUntilFinished){} 

     @Override 
     public void onFinish(){ 
       //set the new Content of your activity 
       YourActivity.this.setContentView(R.layout.main); 
     } 
    }.start(); 
} 
+0

+、CountDownTimerの素敵なトリック –

2

setVisibility(Visibility.GONE)を取得するイメージビューを使用できます。その程度まで何かをするか、時間がたつとポップアップしてドロップアウトするアクティビティを書くことができます。それはあなたの個人的な好みです...

0

なぜですか?ユーザーは待たされることはありません。しかし、あなたには、いくつかのデータをロードしているので、あなたは待つ必要がある場合は、次のことができます。ここでは

public void onCreate(Bundle savedInstanceState){ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash); 

    /* Do some work in a new thread, calling setContentView at the end with your view */ 
} 
0
package com.karan.android.video; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class splash extends Activity 
{ 

    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash); 
     Thread splashThread = new Thread() 
     { 
     @Override 
     public void run() 
     { 
      try { 
       int waited = 0; 
       while (waited < 3000) 
       { 
        sleep(100); 
        waited += 100; 
       } 
      } catch (InterruptedException e) 
      { 
       // do nothing 
      } finally 
      { 
       finish(); 
       Intent i = new Intent(splash.this,video.class); 
       startActivity(i); 
      } 
     } 
     }; 
     splashThread.start(); 
    } 
} 

Xml file: 

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <ImageView   
     android:src="@drawable/buff"  
     android:id="@+id/ImageView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
     </ImageView> 

    <TextView 
    android:textSize="40dp" 
    android:textColor="#CCFF00"  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:text="Buffering..." 
    /> 


</FrameLayout> 
0

遅延実行はsimplier方法で実装することができます。

new Handler().postDelayed(new Runnable() { 
    // ... Hide splash image and show the real UI 
}, 3000) 

またAndroidの標準android.widget.ViewSwitcherクラスは、物事のこの種の非常に使用可能です。

関連する問題