Code example for ViewFlipper

Methods: getTagaddViewsetDisplayedChild

3
		 
		// if this is NetWorkView 
		/** 
		 * Modified by LiYongNam_3rd 2012.12.16_start 
		 */ 
		Object mTag = mViewFlipper.getTag();
		if ( mTag == null ) return;
		 
		String strTag = ( String ) mTag;
		if ( strTag.equalsIgnoreCase( "NetworkView" ) ){
			switch( child ){
				case 2: 
				case 15: 
				case 16: 
					hideBannerBar(); 
					break;				 
				default: 
					showBannerBar(); 
					break;			 
			} 
		} 
		else if ( strTag.equalsIgnoreCase( "UserMusic" ) ){
			switch( child ){
			case 4:			 
				hideBannerBar(); 
				break;				 
			default: 
				showBannerBar(); 
				break;			 
		} 
		} 
		 
		/** 
		 * Modified by LiYongNam_3rd 2012.12.16_end 
		 */ 
	} 
	 
	/** 
	 * Added by LiYongNam 2012.11.14_end 
	 */ 
	 
 
	/** 
	 * Added by LiYongNam 2012.10.2_start 
	 */ 
	public void addLVWLM(GyAdapter<?> gyAdapter,
			OnItemClickListener itemClickListener,
			OnClickListener loadMoreClickListener,
			boolean isGrid, int columnNum) {
		 
			ListViewWithLoadMore lvwlm = creatLVWLM(gyAdapter, itemClickListener,
				loadMoreClickListener, isGrid, columnNum);		
 
			mListViewList.add(lvwlm);
 
			mViewFlipper.addView(lvwlm);
 
			if (-1 == mLvwlmShowing) {
				show(0); 
			} 
	} 
	 
	/** 
	 * Added by LiYongNam 2012.10.2_end 
	 */ 
	 
	 
 
	public void addLVWLM(GyAdapter<?> gyAdapter,
			OnItemClickListener itemClickListener,
			OnClickListener loadMoreClickListener) {
 
		ListViewWithLoadMore lvwlm = creatLVWLM(gyAdapter, itemClickListener,
				loadMoreClickListener, false, 0);	
 
		mListViewList.add(lvwlm);
 
		mViewFlipper.addView(lvwlm);
 
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
	} 
	 
	/** 
	 * Modify by LiYongNam 2012.9.25_start            FooterView With RemoveButton 
	 */ 
	public void addLVWLMAndRF(GyAdapter<?> gyAdapter,
			OnItemClickListener itemClickListener,			
			OnClickListener loadMoreClickListener,
			OnClickListener removeRecordClickListner) {
 
		ListViewWithLoadMore lvwlm = creatLVWLM(gyAdapter, itemClickListener,
				loadMoreClickListener, false, 0);		
		 
		lvwlm.setRemoveFooterViewVisible( true );
		lvwlm.setOnRemoveRecordClickListener( removeRecordClickListner );
		 
		mListViewList.add(lvwlm);
 
		mViewFlipper.addView(lvwlm);
 
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
	} 
	/** 
	 * Modify by LiYongNam 2012.9.25_end 
	 */ 
	 
	public void addClassifyListView( ClassifyLVAdapter lvAdapter,
			OnItemClickListener itemClickListener ) {			
 
		/*LinearLayout mContent = new LinearLayout( getContext() ); 
		mContent.setOrientation( LinearLayout.VERTICAL ); 
		mContent.setLayoutParams( new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) ); 
		 
		TextView tv = new TextView( getContext() ); 
		tv.setText( "ר��" ); 
		tv.setTextSize( 14 ); 
		tv.setTextColor( Color.WHITE ); 
		 
		tv.setLayoutParams( new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ) ); 
		tv.setPadding( Util.dipTopx( getContext(), 20),  
				Util.dipTopx(getContext(), 5),  
				Util.dipTopx( getContext(), 20), 
				Util.dipTopx(getContext(), 5) ); 
		mContent.addView( tv ); 
		 
		ImageView iv = new ImageView( getContext() ); 
		iv.setLayoutParams( new LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ) ); 
		iv.setBackgroundResource( R.drawable.music_list_parting ); 
		mContent.addView( iv );*/ 
		 
		 
		ListView lv = new ListView( getContext() );
		lv.setLayoutParams( new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );
		lv.setCacheColorHint( 0x00000000 );
		lv.setAdapter( lvAdapter );		
		lv.setOnItemClickListener( itemClickListener );	
		lv.setDivider(getResources().getDrawable( R.drawable.music_list_parting ) );
		lv.setSelector( R.drawable.music_list_bg );
		//mContent.addView( lv ); 
 
		mViewFlipper.addView( lv );
		 
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
		 
	} 
	 
	public void addRankGridView( RankGVAdapter gvAdapter, OnItemClickListener itemClickListener, int numColumns ){
		GridView gv = new GridView( getContext() );
		gv.setLayoutParams( new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );			
		 
		gv.setNumColumns(numColumns);
		gv.setGravity(Gravity.CENTER);
		gv.setVerticalSpacing(Util.dipTopx(getContext(), 5));
		gv.setHorizontalSpacing(Util.dipTopx(getContext(), 5));
		gv.setPadding(Util.dipTopx(getContext(), 10),
				Util.dipTopx(getContext(), 10),
				Util.dipTopx(getContext(), 5), 0);
		 
		gv.setAdapter( gvAdapter );
		gv.setOnItemClickListener( itemClickListener );		
		gv.setSelector( R.drawable.music_list_bg );
		//gv.setSelector( R.drawable.transblock ); 
		 
		mViewFlipper.addView( gv );
		 
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
	} 
	 
	public void addGridLM(GyAdapter<?> gyAdapter,
			OnItemClickListener itemClickListener,
			OnClickListener loadMoreClickListener, int numColumns) {
 
		ListViewWithLoadMore lvwlm = creatLVWLM(gyAdapter, itemClickListener,
				loadMoreClickListener, true, numColumns);
 
		mListViewList.add(lvwlm);
 
		mViewFlipper.addView(lvwlm);
 
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
	} 
 
	/** 
	 * ͨ�����򷽷�����һ����׼��ListViewC 
	 *  
	 * @param gyAdapter 
	 * @param itemClickListener 
	 * @param loadMoreClickListener 
	 * @return 
	 */ 
	public ListViewWithLoadMore creatLVWLM(GyAdapter<?> gyAdapter,
			OnItemClickListener itemClickListener,
			final OnClickListener loadMoreClickListener, boolean isGrid,
			int number) {
		final ListViewWithLoadMore lvwlm = new ListViewWithLoadMore(
				getContext(), isGrid, number);
		lvwlm.setGyAdapter(gyAdapter);
		lvwlm.setOnItemClickListener(itemClickListener);
		if (null != loadMoreClickListener) {
			lvwlm.setOnNextPageClickListener(loadMoreClickListener);
 
//			lvwlm.setOnScrollListener(new OnScrollListener() { 
//				@Override 
//				public void onScrollStateChanged(AbsListView view, 
//						int scrollState) { 
//					switch (scrollState) { 
//					case OnScrollListener.SCROLL_STATE_IDLE: 
////						System.out.println(view.getLastVisiblePosition() == (view 
////								.getCount() - 1)); 
////						if (view.getLastVisiblePosition() == (view.getCount() - 1) 
////								&& lvwlm.isLoadMoreShowing() 
////								&& !lvwlm.isBindingTask()) { 
////							System.out.println("��һҳ"); 
////							loadMoreClickListener.onClick(view); 
////						} 
//					} 
// 
//				} 
// 
//				@Override 
//				public void onScroll(AbsListView view, int firstVisibleItem, 
//						int visibleItemCount, int totalItemCount) { 
//					 
//				} 
//			}); 
		} 
 
		return lvwlm;
	} 
 
	/** 
	 * �����Զ���View 
	 */ 
	public void addView(View view) {
		mViewFlipper.addView(view);
		if (-1 == mLvwlmShowing) {
			show(0); 
		} 
	} 
 
	public void addLVWLM(ListViewWithLoadMore lvwlm) {
		mListViewList.add(lvwlm);
	} 
 
	public ListViewWithLoadMore getLVWLM(int location) {
		return mListViewList.get(location);
	} 
 
	public void show( int whichChild ) {
//		System.out.println("#on show  mLvwlmShowing:  "+ whichChild); 
		mUpShowing = mLvwlmShowing;
		mLvwlmShowing = whichChild;
		mViewFlipper.setDisplayedChild(whichChild);
		 
		/** 
		 * Added by LiYongNam 2012.11.14_single 
		 */ 
		showOrHideBannerBar( whichChild );