How to preserve view's animation result?

Put your problem here if it does not fit any of the other categories.

How to preserve view's animation result?

Postby cabernet1976 » Tue May 13, 2008 2:32 am

Hi All,

I have seen a thread in google android developers as below, but not same as my question:
http://groups.google.com/group/android- ... df290dd23e

In my scenario, there are several views, I want to make them run animation then preserve the animation result. In my code as below, there are two menu items, click the frist menu item will make a TextView do animation, and click another will make a ImageView do animation. But I find every time click one of those menu items, the last animation result will be clear and reset to its init state before animation.

Could you help to tell how to preserve view's animation result?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     @Override
  3.  
  4.     public boolean onOptionsItemSelected(Item item) {
  5.  
  6.             switch (item.getId()) {
  7.  
  8.         case MENU_ANIM:
  9.  
  10.                 TextView animWindow = (TextView)findViewById(R.id.anim);
  11.  
  12.  
  13.  
  14.                 // Load the animation from XML (XML file is res/anim/move_animation.xml).
  15.  
  16.                     Animation anim = AnimationUtils.loadAnimation(MyAnimation2.this, R.anim.move_animation);
  17.  
  18.                     anim.setRepeatMode(Animation.NO_REPEAT);
  19.  
  20.  
  21.  
  22.                     // Play the animation.
  23.  
  24.                     animWindow.startAnimation(anim);
  25.  
  26.             break;
  27.  
  28.            
  29.  
  30.         case MENU_ANIM_IMAGE:
  31.  
  32.                 ImageView animImage = (ImageView) findViewById(R.id.anim_image);
  33.  
  34.  
  35.  
  36.             // Load the animation from XML (XML file is res/anim/move_animation.xml).
  37.  
  38.             Animation anim1 = AnimationUtils.loadAnimation(MyAnimation2.this, R.anim.move_animation);
  39.  
  40.             anim1.setRepeatMode(Animation.NO_REPEAT);
  41.  
  42.  
  43.  
  44.             //animImage.setImageDrawable(getResources().getDrawable(R.drawable.test));
  45.  
  46.                 animImage.startAnimation(anim1);
  47.  
  48.                 break;
  49.  
  50.                
  51.  
  52.         default:
  53.  
  54.             break;
  55.  
  56.         }
  57.  
  58.  
  59.  
  60.         return super.onOptionsItemSelected(item);
  61.  
  62.     }
  63.  
  64.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Note: I use the anim XML from
http://code.google.com/android/referenc ... descr.html

Thank you very much.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Postby cabernet1976 » Wed May 14, 2008 3:04 am

Somebody help me?
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 10 guests