Code example for RadioGroup

Methods: getChildCountcheckgetCheckedRadioButtonId, getWidth

0
	private void startActivityGroup(int id) {
		View view = null;
		mLayout.removeAllViews();
		switch (id) {
			case 1: 
				mRadioGroup.check(1);
				view = getLocalActivityManager()
						.startActivity("tab1", new Intent(this, Tab1Activity.class)).getDecorView();
				break; 
			case 2: 
				mRadioGroup.check(2);
				view = getLocalActivityManager()
						.startActivity("tab2", new Intent(this, Tab2Activity.class)).getDecorView();
				break; 
			case 3: 
				mRadioGroup.check(3);
				view = getLocalActivityManager()
						.startActivity("tab3", new Intent(this, Tab3Activity.class)).getDecorView();
				break; 
			case 4: 
				mRadioGroup.check(4);
				view = getLocalActivityManager()
						.startActivity("tab4", new Intent(this, Tab3Activity.class)).getDecorView();
				break; 
			case 5: 
				mRadioGroup.check(5);
				view = getLocalActivityManager()
						.startActivity("tab5", new Intent(this, Tab3Activity.class)).getDecorView();
				break; 
			case 6: 
				mRadioGroup.check(6);
				view = getLocalActivityManager()
						.startActivity("tab6", new Intent(this, Tab3Activity.class)).getDecorView();
				break; 
			case 7: 
				mRadioGroup.check(7);
				view = getLocalActivityManager()
						.startActivity("tab7", new Intent(this, Tab3Activity.class)).getDecorView();
				break; 
		} 
		final int totalWidth = mRadioGroup.getWidth();
		final int childWidth = totalWidth / mRadioGroup.getChildCount();
		final int index = mRadioGroup.getCheckedRadioButtonId() - 1;
		final int childLeft = mRadioGroup.getChildAt(index).getLeft() - mHorizontalScrollView.getScrollX();
		final int centerLine = mHorizontalScrollView.getWidth() / 2;
		if(childLeft > centerLine){
			mHorizontalScrollView.smoothScrollBy(childWidth, 0);
		}else{