From the project I have done, almost all of the start page, the role of the start page can be played ads, post, do cache processing, update data and so on! Android implementation of the start page jump, is to open an Android phone app welcome interface after the jump to the specified interface, let me briefly introduce the more common starting page of the Jump method bar.
first, set a timer in the OnCreate, and then set up intent to point to the activity you want to invoke. Set Timer Any second after the execution of StartActivity can! (Timer is a timer tool that is used to schedule a specified task in a background thread, and it can schedule a task to be executed once or repeatedly)
Final Intent it = new Intent (this, activity1.class); You have to turn to the activity
Timer timer = new timer ();
TimerTask task = new TimerTask () {
@Override public
void Run () {
startactivity (it);//Execute
}
};
Timer.schedule (Task, 1000 * 10); 10 seconds later
Second, the use of child threads in the Run method to set the jump, with handler to execute.
public class Welcomeactivity extends activity {
@Override
protected void onCreate (Bundle savedinstancestate) { C3/><span style= "White-space:pre" > </span>//TODO auto-generated method stub
<span style= " White-space:pre "> </span>super.oncreate (savedinstancestate);
<span style= "White-space:pre" > </span>setcontentview (r.layout.welcome);
<span style= "White-space:pre" > </span>new Handler (). postdelayed (R, 1000);//1 seconds after closing, and jump to Main page face
}
Runnable r = new Runnable () {
@Override public
void Run () {
//TODO auto-generated method stub
Intent i ntent = new Intent ();
Intent.setclass (Welcomeactivity.this, mainactivity.class);
StartActivity (intent);
Finish ();}}
;
third, in the form of animation (rotation, scaling, etc.) as a starting page, this method in the project is also more commonly used, than the first method more animation set, the specific look code comments!
Start Animation page Layout Splashmain.xml
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:layout_width=" match_parent "
android:layout_height=" match_parent ">
< ImageView
android:id= "@+id/iv_splash_mainview"
android:layout_width= "fill_parent"
android:layout_ height= "Fill_parent"
android:background= "@drawable/splash_bg"
android:src= "@drawable/splash_sheep_n" >
</LinearLayout>
Start Animation page Splashactivity.java
public class <span style= "Font-family:arial, Helvetica, Sans-serif;" >splash</span><span style= "font-family:arial, Helvetica, Sans-serif;"
>activity extends activity {</span> private ImageView Iv_mainview;
Private animationset as; @Override protected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method stub Super.oncre
Ate (savedinstancestate);
Remove the title //requestwindowfeature (window.feature_no_title);
Initview ()//Initialize interface startanimation ()//Start animation initevent ()//Initialize event} private void Initevent () {
1, listening to the animation playback of the event, just a use of the event on the anonymous class object, multiple declarations of member variables with As.setanimationlistener (new Animationlistener () {@Override public void Onanimationstart (Animation Animation) {} @Override public void Onanima Tionrepeat (Animation Animation) {}//listening for animation playback @Override public void Onanimationend (Animati On animation) {
Intent main = new Intent (<span style= "font-family:arial, Helvetica, Sans-serif;" >splash</span><span style= "font-family:arial, Helvetica, Sans-serif;" >activity </span><span style= "font-family:arial, Helvetica, Sans-serif;"
>.this,mainactivity.class);</span> startactivity (main);//main interface//close oneself finish ();
}
});
/** * starts to play Animation: rotate, zoom, gradient/private void startanimation () {//False represents an animation set with each animation insert (numeric function)
as = new Animationset (false);
Rotate animation, Anchor point rotateanimation RA = new Rotateanimation (0, 360, animation.relative_to_self, 0.5f,
animation.relative_to_self,0.5f)//Set the anchor point for the picture's center point//Set the animation playback Time Ra.setduration (2000);
Ra.setfillafter (TRUE);//After the animation is finished, stay in the current state//Add to the animation set as.addanimation (RA); Gradient animation alphaanimation AA = new Alphaanimation (0, 1);//from fully transparent to opaque//aa.setduration (2000);
Aa.setfillafter (TRUE),///As.addanimation (AA);
Zoom animation scaleanimation sa = new Scaleanimation (0, 1, 0, 1, animation.relative_to_self, 0.5f,
Animation.relative_to_self, 0.5f);
Sa.setduration (2000);
Sa.setfillafter (TRUE);///As.addanimation (SA);
Play animation iv_mainview.startanimation (AS); After the animation is finished, enter the next interface: The wizard interface or the main interface//1, listen to the event that the animation is finished} private void Initview () {//Set the main interface Setcontentvie
W (R.layout.onemain);
Get background picture Iv_mainview = (ImageView) Findviewbyid (R.id.iv_splash_mainview); }
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.