Android ViewAnimator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ViewAnimator class.

This code example shows how to use the following methods:setInAnimation, setOutAnimation
	public void goNext(String url) {
		Animation out = AnimationUtils.loadAnimation(context,
				android.R.anim.slide_out_right);
		Animation in = AnimationUtils.loadAnimation(context,
				android.R.anim.slide_in_left);
		viewAnimator.setInAnimation(in);
		viewAnimator.setOutAnimation(out);
		this.url = url;
		setWebView(); 
	} 
 
	public void goPrevious(String url) {
		Animation out = AnimationUtils.loadAnimation(context, R.anim.fade_in);
		Animation in = AnimationUtils.loadAnimation(context, R.anim.fade_out);
		viewAnimator.setInAnimation(in);
		viewAnimator.setOutAnimation(out);
		this.url = url;
		setWebView(); 
	} 
 
7
CodeRank
This code example shows how to use the following methods:setInAnimation, setOutAnimation, showPrevious
This code example shows how to use the following methods:getChildAt, getChildCount, getCurrentView, getDisplayedChild, setDisplayedChild
	 * @param viewAnimator the {@code ViewAnimator} 
	 * @param dir the direction of flip 
	 */ 
	public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir, long duration) {   
		 
		final View fromView = viewAnimator.getCurrentView();
		 
		final int currentIndex = viewAnimator.getDisplayedChild();
		final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();
		 
		final View toView = viewAnimator.getChildAt(nextIndex);
 
		Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, duration);
   
		viewAnimator.setOutAnimation(animc[0]);
		viewAnimator.setInAnimation(animc[1]);
		 
		viewAnimator.setDisplayedChild(nextIndex); 
	} 
	 

6
CodeRank
This code example shows how to use the following methods:showNext
     
    flipper=(ViewFlipper)findViewById(R.id.details);
  } 
   
  public void flip(View v) {
    flipper.showNext();
  } 
} 
7
CodeRank
This code example shows how to use the following methods:setLayoutParams, addView, setDisplayedChild
		// Flipper layout 
		LayoutParams flipperParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		flipperParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
		 
		iconFlipper = new SafeViewFlipper(getContext());
		iconFlipper.setLayoutParams(flipperParams);
		iconFlipper.addView(imageLayout, 0);
		iconFlipper.addView(progressLayout, 1);
		iconFlipper.setDisplayedChild(0);	
 
		 
/****************************************** 
 * Assembly 
 ******************************************/		 
		addView(iconFlipper);
		addView(textLayout);
	} 
 
	public void setDisplayUtils(DisplayUtils deviceUtils) {
		this.displayUtils = deviceUtils;
7
CodeRank
This code example shows how to use the following methods:getContext, setText, setInAnimation, setOutAnimation, setFactory
 
    /** 
     * Initializes the score TextSwitcher for the specified {@code textSwitcher}. 
     */ 
    private void initializeTextSwitcher(final TextSwitcher textSwitcher) {
        textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
            @Override 
            public View makeView() {
                TextView textView = new TextView(textSwitcher.getContext());
                textView.setTextSize(26);
                return textView;
            } 
        }); 
 
        textSwitcher.setInAnimation(AnimationUtils.loadAnimation(textSwitcher.getContext(), android.R.anim.fade_in));
        textSwitcher.setOutAnimation(AnimationUtils.loadAnimation(textSwitcher.getContext(), android.R.anim.fade_out));
        textSwitcher.setText("1");
    } 
 
} 

6
CodeRank
This code example shows how to use the following methods:getCurrentView, setInAnimation, setOutAnimation, showNext, showPrevious
This code example shows how to use the following methods:addView, setInAnimation, setOutAnimation, showNext
						//could also be the action listener which is invalid 
						//ongoingAnimation=false; 
					}else { 
						 
						viewAnimator = (ViewAnimator)currentView;
						viewAnimator.addView(unboundNewView);
						//setup animation 
						 
						viewAnimator.setInAnimation(inAnimation);
						viewAnimator.setOutAnimation(outAnimation);
						//trigger the animation and the event listener when finished 
						ongoingAnimation=true;
						viewAnimator.showNext();
						 
					} 
				} 
				return true; 
			} 
 
			return super.onKeyDown(keyCode, event);
6
CodeRank
This code example shows how to use the following methods:invalidate, setDisplayedChild, setInAnimation, setOutAnimation
    	int size = mIdList.size();
        if (size > 1) 
        { 
            String topId = mIdList.pop();
            Intent intent = mIntents.get(topId);
            mAnimator.setInAnimation(getAnimation(intent, false, true));
            Animation outAnim = getAnimation(intent, false, false);
            outAnim.setAnimationListener(new BackAnimationListener(topId));
            mAnimator.setOutAnimation(outAnim);
            mAnimator.setDisplayedChild(mIdList.size() - 1);
            mAnimator.invalidate();
        } 
    } 
     
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) 
    { 
        if (keyCode == KeyEvent.KEYCODE_BACK) 
        {        	 
        	int size = mIdList.size();
6
CodeRank
This code example shows how to use the following methods:addView, getChildAt, getChildCount, removeViewAt, setInAnimation
	 * TODO remove 
	 * May return null 
	 */ 
	@Deprecated 
	public static View swap(ViewAnimator flipper, View view, Animation in, Animation out) {
		flipper.setInAnimation(in);
		flipper.setOutAnimation(out);
		 
		View returned = null;
		 
		if (flipper.getChildCount() == 2) {
			returned = flipper.getChildAt(0);
			flipper.removeViewAt(0);
		} 
		 
		flipper.addView(view);
		flipper.showNext();
		 
		return returned;
	} 

6
CodeRank

Related Android ViewAnimator Questions & Answers:

See Code Examples for Android ViewAnimator Methods: