Animation jumps between Android tabactivity and activity (the animation effect that jumps out in the main tabhost resolves)

Source: Internet
Author: User

First of all, to say is the Activitya to Activityb of the relatively simple switch, as long as Overridependingtransition (In,out). I won't say it here. But here to say the name of the Activitya can not tabhost one inside. Because Tabhost inside has its own activity actually did not jump out of tabhost life. This can be log,tabhost the life cycle of the test will know. In fact tabhost inside nested activity all in the life cycle are in tabhost inside. In this case, the activity inside the tabhost jumps to the other (non-tabhost activity), calling Overridependingtransition (In,out). The jump effect is still the default, so the effect of the code will not appear.

For example:

You click on a child of the ListView inside. Jump out of Tabhost you call Overridependingtransition (In,out) in the Click event. It's no use.

Now solve this problem: Because Tabhost also has its own default overridependingtransition () method, I solve the method is to inherit Overridependingtransition (In,out) is called in the OnPause () method of the tabactivity activity. In,out This two parameter is placed inside a class. This way, you can call the method that modifies the two parameters where you want to go. Code:
 Public classAnimcommon { Public Static int inch=0; Public Static int  out=0; Public Static void Set(intAintb) {inch=A; out=b;} Public Static voidClear () {inch=0; out=0;}}

The following is the Tabactivity class of OnPause ()

@Override protected void OnPause () {System. out. println ("pause"); if (Animcommon. in! =0 && Animcommon. Out! =0) {super.overridependingtransition (Animcommon. in, Animcommon.  out ); Animcommon.clear ();} Super.onpause ();}

Here is the code for the jump:

New Intent (informactivity.  this, informitemactivity. class ); Animcommon. Set (R.anim.zoom_enter,r.anim.zoom_exit); startactivity (intent);

Animation jumps between Android tabactivity and activity (the animation effect that jumps out in the main tabhost resolves)

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.