package ti.modules.titanium.ui.widget;

import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

/**
 * Tab group implementation using the Action Bar navigation tabs.
 * 
 * When the target SDK version and device framework level is 11 or higher
 * we will use this implementation to place the tabs inside the action bar.
 * Each tab window provides a fragment which is made visible by a fragment
 * transaction when it is selected.
 * 
 * See http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
 * for further details on how Action bar tabs work.
 */
public class TiUIActionBarTabGroup extends TiUIView {

	public TiUIActionBarTabGroup(TiViewProxy proxy) {
		super(proxy);
	}

}

@@ -70,73 +70,212 @@
 ium.
-proxy
+view
 .Ti
+UI
 View
-Proxy;%0Aimport org.appcelerator.titanium.view.TiUIView
+;%0A%0Aimport ti.modules.titanium.ui.TabGroupProxy;%0Aimport android.app.ActionBar.Tab;%0Aimport android.app.ActionBar.TabListener;%0Aimport android.app.Fragment;%0Aimport android.app.FragmentTransaction
 ;%0A%0A/
@@ -792,17 +792,532 @@
 iUIView 
-%7B
+implements TabListener %7B%0A%0A%09private static class TabInfo %7B%0A%09%09/*%0A%09%09 * The fragment that will provide the content view of the tab.%0A%09%09 * This fragment will be attached when the tab is selected and%0A%09%09 * detached when it is later unselected.%0A%09%09 */%0A%09%09public Fragment fragment;%0A%0A%09%09/*%0A%09%09 * Tracks if this tab's fragment has been attached yet.%0A%09%09 * This should always be initialized to 'false' and only%0A%09%09 * set to 'true' when the tab has been selected for the first time.%0A%09%09 */%0A%09%09public boolean isFragmentAttached = false;%0A%09%7D
 %0A%0A%09publi
@@ -1345,13 +1345,15 @@
 up(T
-iView
+abGroup
 Prox
@@ -1383,10 +1383,1065 @@
 y);%0A%09%7D%0A%0A
+%09@Override%0A%09public void onTabSelected(Tab tab, FragmentTransaction ft) %7B%0A%09%09TabInfo tabInfo = (TabInfo) tab.getTag();%0A%0A%09%09if (!tabInfo.isFragmentAttached) %7B%0A%09%09%09// When the tab is first selected we must attach%0A%09%09%09// the tab fragment to the tab group's activity.%0A%09%09%09// At the same time we will also place the fragment's%0A%09%09%09// view into the content container.%0A%09%09%09ft.add(android.R.id.content, tabInfo.fragment);%0A%09%09%09tabInfo.isFragmentAttached = true;%0A%0A%09%09%7D else %7B%0A%09%09%09// If the tab's fragment is already attached to the activity%0A%09%09%09// we just need to re-attach it to make it visible once again.%0A%09%09%09ft.attach(tabInfo.fragment);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void onTabUnselected(Tab tab, FragmentTransaction ft) %7B%0A%09%09TabInfo tabInfo = (TabInfo) tab.getTag();%0A%0A%09%09// When the tab is unselected remove the fragment's view and%0A%09%09// detach the fragment from the activity. We need to clear the%0A%09%09// tab group's content area for the next tab that gets selected.%0A%09%09ft.detach(tabInfo.fragment);%0A%09%7D%0A%0A%09@Override%0A%09public void onTabReselected(Tab tab, FragmentTransaction ft) %7B%0A%09%7D%0A%0A
 %7D%0A

Implement the TabListener interface.