Enable animation for Android apps

Source: Internet
Author: User

For example: A.java to start the animation, and then into the B.java

1.a.java

protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
LOG.I ("Start animation", "Start animation");
Remove title
Requestwindowfeature (Window.feature_no_title);
Set Full Screen
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

Setcontentview (R.layout.activity_start);
Turn on animation duration
New Handler (). postdelayed (New Runnable () {

@Override
public void Run () {
TODO auto-generated Method Stub
Intent intent=new Intent (Startactivity.this,
Mainactivity.class);
Startactivityforresult (intent,10);


}
}, 1000*2);
}



@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
TODO auto-generated Method Stub
LOG.I ("startactivity+ has data return", requestcode+ "");
Super.onactivityresult (Requestcode, ResultCode, data);
if (resultcode==20) {
Finish ();
}
}

2.b.java

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Set the response so that startactivity () closes itself
Setresult (20);
Setcontentview (R.layout.activity_main);



}

Explain

1.new Handler (). postdelayed (New Runnable () {... }

Delay Intent Jump

2.startActivityForResult (intent,10);

Parameters:(Intent Intent, Int requestcode)

Requestcode is used for later destruction.

3. Onactivityresult (int requestcode, int resultcode, Intent data) {

ResultCode: Represents the data returned by B.java, which is sent when the B.java is started.

A.java according to the data, destroy themselves.

4.Setresult (20);

The data that is set in B.java is returned to A.java, andA.java is destroyed according to the data itself.



Enable animation for Android apps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.