Code example for ObjectAnimator

Methods: addListener, addUpdateListener, setDuration, start

0
		final float progress = (1);
		final ObjectAnimator progressBarAnimator = ObjectAnimator.ofFloat(progressBar, "progress", progresses);
		 
		 
		setObjectAnimation(progressBarAnimator);          //set ObjectAnimation对象
		progressBarAnimator.setDuration(NUM_SHOW_TIME);   //设置Animation的时间
		progressBarAnimator.addListener(new AnimatorListener() { //添加Listener
 
			@Override 
			public void onAnimationCancel(final Animator animation) {
				 
			} 
 
			@Override 
			public void onAnimationEnd(final Animator animation) {
				//在此启动摔倒警报 
			} 
 
			@Override 
			public void onAnimationRepeat(final Animator animation) {
			} 
 
			@Override 
			public void onAnimationStart(final Animator animation) {
			} 
		}); 
		progressBarAnimator.addListener(listener);
		 
		//当animation更新时回调 
		progressBarAnimator.addUpdateListener(new AnimatorUpdateListener() {
			 
			/** 
			 * 每过一秒,发送一个Message 
			 *  
			 */ 
			private int timeShow = 0;
			@Override 
			public void onAnimationUpdate(final ValueAnimator animation) {
				if((int)animation.getCurrentPlayTime() / 1000 != timeShow)
				{ 
					timeShow = (int)animation.getCurrentPlayTime() / 1000 ;
					Message msg = new Message();
					msg.what = 0x1234 ;
					bundle.putInt(BUNDLE_KEY, timeShow) ;
					myHandler.sendMessage(msg);
				} 
				progressBar.setProgress((Float) animation.getAnimatedValue());
			} 
		}); 
		progressBar.setMarkerProgress(progress);
		progressBarAnimator.start();
	} 
	 
	/** 
	 * 设置和取得ObjectAnimator的引用 
	 */