ViewAnimator setDisplayedChild - top ranked examples from Open Source projects

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

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: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:addView, setDisplayedChild, setInAnimation, setOutAnimation
        mIntents.put(id, intent);
        System.out.println("adding " + intent);
 
        View view = mActivityManager.startActivity(id, intent).getDecorView();
        int size = mIdList.size();
        mAnimator.setInAnimation(size > 1? getAnimation(intent, true, true) : null);
        mAnimator.setOutAnimation(size > 1? getAnimation(intent, true, false) : null);
        mAnimator.addView(view);
        mAnimator.setDisplayedChild(mIdList.size() - 1);
    } 
     
    public void startChildActivity(String id1,Intent intent)
    { 
    	System.out.println("starting " + intent);
    	String id = "id" + mSerial++;
        mIdList.push(id);
        mIntents.put(id, intent);
        System.out.println("adding " + intent);
 
        View view = mActivityManager.startActivity(id, intent).getDecorView();
6
CodeRank
This code example shows how to use the following methods:getInAnimation, getOutAnimation, setDisplayedChild, setInAnimation, setOutAnimation
     * Set the displayed child. 
     *  
     * @param whichChild 
     */ 
    private void setDisplayedChild(int whichChild) {
        Animation lastOutAnim = mViewFlipper.getOutAnimation();
        Animation lastInAnim = mViewFlipper.getInAnimation();
        mViewFlipper.setOutAnimation(null);
        mViewFlipper.setInAnimation(null);
        mViewFlipper.setDisplayedChild(whichChild);
        mViewFlipper.setOutAnimation(lastOutAnim);
        mViewFlipper.setInAnimation(lastInAnim);
    } 
 
    /** 
     * Find the view flipper in the content view. 
     */ 
    private void findViewFlipper() { 
        mViewFlipper = (ViewFlipper) findViewById(R.id.viewflipper);
        if (mViewFlipper == null) {
6
CodeRank
This code example shows how to use the following methods:getTag, setPadding, setTag, addView, getChildAt
	public View getView(int position, View convertView, ViewGroup parent) {
    	final ViewSwitcher lViewSwitcher;
		String url = mUrls[position];
		ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
        	lViewSwitcher = new ViewSwitcher(mContext);
			lViewSwitcher.setPadding(0, 0, 0, 0);
			ProgressBar lProgress = new ProgressBar(mContext);
			lProgress.setLayoutParams(new ViewSwitcher.LayoutParams(40, 40));
			lViewSwitcher.addView(lProgress);
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(5, 5, 5, 5);
            lViewSwitcher.addView(imageView);
             
            // attach the onclick listener 
			//lViewSwitcher.setOnClickListener(new ClickHandler()); 
        } else { 
        	lViewSwitcher = (ViewSwitcher) convertView;

6
CodeRank
This code example shows how to use the following methods:scrollTo, setDisplayedChild, setInAnimation, setOutAnimation
5
CodeRank
This code example shows how to use the following methods:addView, setDisplayedChild
    public void startActivity(Intent intent) {
        System.out.println("starting " + intent);
        String id = "id" + mSerial++;
        mIds.push(id);
        View view = mActivityManager.startActivity(id, intent).getDecorView();
        mAnimator.addView(view);
        mAnimator.setDisplayedChild(mIds.size() - 1);
    } 
     
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            int size = mIds.size();
            if (size > 0) {
                String topId = mIds.pop();
                View view = mActivityManager.destroyActivity(topId, true).getDecorView();
                mAnimator.removeView(view);
                if (size > 1) {
                    return true; 
                } 
5
CodeRank
This code example shows how to use the following methods:scrollTo, setDisplayedChild, setInAnimation, setOutAnimation
5
CodeRank
This code example shows how to use the following methods:setAnimateFirstView, setDisplayedChild
This code example shows how to use the following methods:setDisplayedChild, setInAnimation, setOutAnimation
			VF.setOutAnimation(anim(0F,-1F));
 
		} 
		else if(!flag && isNotif){
			isNotif =false;
			VF.setDisplayedChild(1);
			VF.setInAnimation(anim(-1F,0F));
			VF.setOutAnimation(anim(0F,1F));
 
		} 
	} 
} 
5
CodeRank

Related ViewAnimator setDisplayedChild Questions & Answers:

setDisplayedChild Method Overview
Sets which child view will be displayed.
See Code Examples for other Android ViewAnimator Methods: