-1

Hi i already made a running project . But it striked me if i can add a page before my first main page like a welcome page without doing much changes . This page after afew seconds should automatically come to my present main page . Please help .

4

3 回答 3

0

It is called splash screen in Android!
A little googling, you have tutorial like this or this.
No major changes needed!
Just add your SplashActivity with its layout.
And change your manifest file and thats about it.

于 2013-09-11T09:16:59.143 回答
0

That page is usually called Splash Screen. Make a new SplashActivity.class and declare this as the launcher activity in AndroidManifest. Then in the SplashActivity.class

public class SplashActivity extends Activity {

// Splash screen timer
private static int SPLASH_TIME_OUT = 5000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    new Handler().postDelayed(new Runnable() {


        @Override
        public void run() {
            // This method will be executed once the timer is over
            // Start your app main activity
            Intent intent = new Intent(SplashActivity.this, MainActivity.class);  //MainActivity is my home activity.
            startActivity(intent );

            // close this activity
            finish();
        }
    }, SPLASH_TIME_OUT);
}

}

于 2013-09-11T09:17:37.950 回答
0

setContentView(launchView) before set mainPage as contentView, then seconds later, setContentView(mainPage).

于 2013-09-11T09:30:52.087 回答