Animated jump between TabActivity and Activity (mainly solves the problem caused by the animation jump from Tabhost)

Source: Internet
Author: User

From: http://blog.sina.com.cn/s/blog_8db8914301010t31.html

First, it is relatively simple to switch from ActivityA to ActivityB, As long as overridePendingTransition (In, out ). I won't talk about it here. However, ActivityA cannot be included in TABHost. Because the Tabhost has its own Activity, but it has not jumped out of the Tabhost life. This can be used for Log and Tabhost lifecycle. In fact, the nested activities in Tabhost are all in the Tabhost lifecycle. In this case, overridePendingTransition (In, out) is called when the Activity In Tabhost jumps to another Activity (not In Tabhost ). The jump effect is still the default, so the effect of such a sentence of code will not appear.

For example:


Click a subitem of ListView. Jump out of Tabhost and you will call overridePendingTransition (In, out) In the click event ). It is useless.

Solve this problem now: Because Tabhost also has its own default overridePendingTransition () method, the solution is to inherit from the onPause () method of TabActivity and call overridePendingTransition (In, out ). Put the In and out parameters In a class. In this way, you can call the method to modify the two parameters at the place to be transferred. Code: public class AnimCommon {public static int in = 0; public static int out = 0; public static void set (int a, int B) {in =; out = B;} public static void clear () {in = 0; out = 0;} below is the onPause () @ Overrideprotected void onPause () {System. out. println ("pause"); if (AnimCommon. in! = 0 & AnimCommon. out! = 0) {super. overridePendingTransition (AnimCommon. in, AnimCommon. out); AnimCommon. clear ();} super. onPause () ;}the following code indicates the redirection: Intent intent = new Intent (InformActivity. this, InformItemActivity. class); AnimCommon. set (R. anim. zoom_enter, R. anim. zoom_exit); startActivity (intent); to solve this problem.

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.