1

我有一个关于在我的应用程序中加载第一个 Activity 的问题。在加载它之前,应用程序会显示这个屏幕:https://www.dropbox.com/s/r33n3u3xfmth345/Screenshot_2013-08-16-12-02-08.png,我想要的是直接加载我的活动。

我会提到我m using SherlockActivity, and I already tried setting the Theme both in Manifest or programatically in onCreate() of my Activity, with same result (pre-load在该屏幕上停留 2-3 秒,然后加载我的活动)。有什么想法吗 ?

4

1 回答 1

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>
于 2013-08-16T09:31:11.623 回答