ViewAnimator getDisplayedChild - 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 getDisplayedChild 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:getChildCount, getDisplayedChild
	protected boolean isFirstDisplayed() { 
		return (flipper.getDisplayedChild() == 0);
	} 
 
	protected boolean isLastDisplayed() { 
		return (flipper.getDisplayedChild() == flipper.getChildCount() - 1);
	} 
 
	protected void updateButtons() { 
		boolean eula = (flipper.getDisplayedChild() == 0);
 
		next.setText(eula ? getString(R.string.wizard_agree) : getString(R.string.wizard_next));
		prev.setText(eula ? getString(R.string.delete_neg) : getString(R.string.wizard_back));
	} 
} 
6
CodeRank
This code example shows how to use the following methods:addView, getCurrentView, getDisplayedChild, showNext
    @Test 
    public void testAnimatorHandlesCyclingViews() { 
        View v1 = new View(null);
        View v2 = new View(null);
         
        animator.addView(v1);
        animator.addView(v2);
         
        animator.showNext();
         
        assertEquals(1, animator.getDisplayedChild());
        assertEquals(v2, animator.getCurrentView());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getDisplayedChild, setInAnimation, setOutAnimation, showNext
				} 
			} 
        }); 
        rightBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				if (animator.getDisplayedChild() == 0) {
			        title.setText("step #2");
			        leftBtn.setText("back");
					rightBtn.setText("ok");
					animator.setInAnimation(slideInLeft);
					animator.setOutAnimation(slideOutLeft);
					animator.showNext();
				} else { 
					String msg = "don't be suprized, but your first name is [" +
						firstName.getText() + "] and your last name is [" +
						lastName.getText() + "]";
					new AlertDialog.Builder(TestCustomTitle.this).setMessage(msg)
						.setTitle("hmmm...")
						.setIcon(android.R.drawable.ic_dialog_info)
						.setPositiveButton("ok", null)
6
CodeRank
This code example shows how to use the following methods:getChildAt, getDisplayedChild, setInAnimation, setOutAnimation, showPrevious
    /** 
     * 前月を表示する 
     * @param direction モーションの方向をセット(DIRECTION_VERTICAL|DIRECTION_HORIZONTAL) 
     */ 
    private void showPreviousMonth(int direction) {
        int index = this.viewFlipper.getDisplayedChild() == 0 ? 1 : 0;
        MonthlyCalendarView calendarView = 
            (MonthlyCalendarView)this.viewFlipper.getChildAt(index);
        if ( calendarView != null ) {
            calendarView.setCalendar(this.calendar);
            this.setHeader(this.calendar.get(java.util.Calendar.YEAR)
                    , calendar.get(java.util.Calendar.MONTH));
            if ( direction == DIRECTION_VERTICAL ) {
                this.viewFlipper.setInAnimation(inFromTop);
                this.viewFlipper.setOutAnimation(outToBottom);
            } else { 
                this.viewFlipper.setInAnimation(inFromLeft);
                this.viewFlipper.setOutAnimation(outToRight);
            } 
            this.viewFlipper.showPrevious();

6
CodeRank
This code example shows how to use the following methods:getDisplayedChild, setInAnimation, setOutAnimation, showNext
				} 
			} 
        }); 
        rightBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				if (animator.getDisplayedChild() == 0) {
			        title.setText("step #2");
			        leftBtn.setText("back");
					rightBtn.setText("ok");
					animator.setInAnimation(slideInLeft);
					animator.setOutAnimation(slideOutLeft);
					animator.showNext();
				} else { 
					String msg = "don't be suprized, but your first name is [" +
						firstName.getText() + "] and your last name is [" +
						lastName.getText() + "]";
					new AlertDialog.Builder(TestCustomTitle.this).setMessage(msg)
						.setTitle("hmmm...")
						.setIcon(android.R.drawable.ic_dialog_info)
						.setPositiveButton("ok", null)
6
CodeRank
This code example shows how to use the following methods:getChildCount, getDisplayedChild, showNext
					// user walked past end of wizard, so return okay 
					WizardActivity.this.setResult(Activity.RESULT_OK);
					WizardActivity.this.finish();
				} else { 
					// show next step and update buttons 
					flipper.showNext();
					updateButtons(); 
				} 
			} 
		}); 
 
		prev = (Button)this.findViewById(R.id.action_prev);
		prev.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				if(isFirstDisplayed()) { 
					// user walked past beginning of wizard, so return that they cancelled 
					WizardActivity.this.setResult(Activity.RESULT_CANCELED);
					WizardActivity.this.finish();
				} else { 
					// show previous step and update buttons 

6
CodeRank
This code example shows how to use the following methods:getChildAt, getChildCount, getCurrentView, getDisplayedChild, setInAnimation
         * @param viewAnimator the {@code ViewAnimator} 
         * @param dir the direction of flip 
         */ 
        public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir) {  
                
                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, (nextIndex < currentIndex?dir.theOtherDirection():dir), 500, null);
  
                viewAnimator.setOutAnimation(animc[0]);
                viewAnimator.setInAnimation(animc[1]);
                
                viewAnimator.showNext();  
        } 
        
        ////////////// 

5
CodeRank
This code example shows how to use the following methods:getChildCount, getDisplayedChild
         
        return false; 
    } 
	 
    public void onClick(View v) {
		if(v.equals(nextButton) && viewFlipper.getDisplayedChild() == viewFlipper.getChildCount()-1) {
		    // last page: the next button results in closing the help page 
		    finish();
		} else if(v.equals(previousButton) && viewFlipper.getDisplayedChild() == 0) {
		    // first page: the previous button results in closing the help page 
		    finish();
		} else if(v.equals(nextButton)){
			showNext(); 
		} else if(v.equals(previousButton)) {
			showPrevious(); 
		} else if(v.equals(sendPublicKeyButton)) {
		    Intent intent = new Intent(this, SendPublicKeyActivity.class);
            startActivity(intent);
		} 
		 
5
CodeRank
This code example shows how to use the following methods:getDisplayedChild, showPrevious
 
            @Override 
            public void onClick(View v) {
                ViewSwitcher switcher = (ViewSwitcher) v;
 
                if (switcher.getDisplayedChild() == 0) {
                    switcher.showNext();
                } else { 
                    switcher.showPrevious();
                } 
            } 
        }); 
    } 
 
} 
5
CodeRank

Related ViewAnimator getDisplayedChild Questions & Answers:

getDisplayedChild Method Overview
Returns the index of the currently displayed child view.
See Code Examples for other Android ViewAnimator Methods: