Calll a method in a Dynamic way: Java

Suppose you have a class called shows below with methods.


 public class ActivityAnimator {  
      public void flipHorizontalAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.flip_horizontal_in,  
                     R.anim.flip_horizontal_out);  
      }  
      public void flipVerticalAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.flip_vertical_in,  
                     R.anim.flip_vertical_out);  
      }  
      public void fadeAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);  
      }  
      public void disappearTopLeftAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.disappear_top_left_in,  
                     R.anim.disappear_top_left_out);  
      }  
      public void appearTopLeftAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.appear_top_left_in,  
                     R.anim.appear_top_left_out);  
      }  
      public void disappearBottomRightAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.disappear_bottom_right_in,  
                     R.anim.disappear_bottom_right_out);  
      }  
      public void appearBottomRightAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.appear_bottom_right_in,  
                     R.anim.appear_bottom_right_out);  
      }  
      public void unzoomAnimation(Activity a) {  
           a.overridePendingTransition(R.anim.unzoom_in, R.anim.unzoom_out);  
      }  
      public void PullRightPushLeft(Activity a) {  
           a.overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);  
      }  
      public void PullLeftPushRight(Activity a) {  
           a.overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right);  
      }  
 }  

Now you can call this your method from any other class like:

 // ===== Inside Another class === //  
      private String[] _animationList = { "fade", "flipHorizontal",  
                "flipVertical", "disappearTopLeft", "appearTopLeft",  
                "appearBottomRight", "disappearBottomRight", "unzoom" };  
 ActivityAnimator anim = new ActivityAnimator();  
 anim.getClass().getMethod(_animationList[arg2] + "Animation",Activity.class).invoke(anim, this);