Code example for ViewSwitcher

Methods: getDisplayedChild, setDisplayedChild

0
		final ViewSwitcher cardFlipper = (ViewSwitcher) getView().findViewById(R.id.cardSwitcher);
		OnClickListener flipViewListener = new OnClickListener(){
			@Override 
			public void onClick(View v) {
				// TODO Auto-generated method stub 
				if(cardFlipper.getDisplayedChild()==0)
					cardFlipper.setDisplayedChild(1);
				else 
					cardFlipper.setDisplayedChild(0);
			} 
		}; 
		RelativeLayout referenceLayout = (RelativeLayout) getView().findViewById(R.id.referenceLayout);
		TextView scriptureText = (TextView) getView().findViewById(R.id.scriptureText);
		referenceLayout.setOnClickListener(flipViewListener);
		scriptureText.setOnClickListener(flipViewListener);
 
		mScriptureReferenceField = (TextView) getView().findViewById(R.id.referenceText);
		mScriptureTextField = (TextView) getView().findViewById(R.id.scriptureText);
 
		//Set up coloring. 
		//Define the front and back of the cards.