2013-08-16 61 views

回答

0

您必須使用閃屏活動,之後你必須從閃屏活動啓動自己的活動

這裏是splashActivity的代碼。

public class SplashActivity extends Activity { 
private int splashTime = 3000; 
private Thread thread; 
private ProgressBar mSpinner; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.activity_splash); 
    mSpinner = (ProgressBar) findViewById(R.id.Splash_ProgressBar); 
    mSpinner.setIndeterminate(true); 
    thread = new Thread(runable); 
    thread.start(); 
} 
public Runnable runable = new Runnable() { 
    public void run() { 
     try { 
      Thread.sleep(splashTime); 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
     } 
     try { 
      startActivity(new Intent(SplashActivity.this,YourActivityName.class)); 
      finish(); 
     } catch (Exception e) { 
      // TODO: handle exception 
     } 
    } 
}; 
} 

這裏是activity_spalsh.xml文件代碼.....

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#48AD83" 
android:orientation="vertical" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:layout_marginBottom="20dp" 
    android:layout_marginTop="10dp" 
    android:gravity="center_horizontal" 
    android:text=" your app name " 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textColor="#A52A2A" /> 

<ProgressBar 
    android:id="@+id/Splash_ProgressBar" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView1" 
    android:layout_centerInParent="true" 
    android:layout_marginTop="5dp" /> 

</RelativeLayout> 
+0

是的,它似乎是它的伎倆..但它可能是另一種方式不顯示該屏幕沒有添加啓動畫面到應用程序? – DoruAdryan