title: Need to display activity according to TAB selected
body: <p>I will try to explain my problem as brief as possible. I have 4 tabs, "Month" "Week" "Day" "Today". Each of these days are a separate activity. When a user clicks "Today" tab, the activity must first check the previous activity, and then accordingly show the current date. For eg. If user has clicked DAY before and then clicks TODAY, the TODAY activity should display today's date. Same goes for both "Month" "Week" activity. The today will check the previous activity and show the current month and current week respectively.</p>
  
  <p><img src="https://i.stack.imgur.com/SOhny.jpg" alt="The TABs: each are a separate activity"></p>
  
  <p>Here is the code I have used to make my Tabs.</p>
  
  <pre><code>public class Secondactivity extends TabActivity {    
       private TabHost mTabHost;
       private void setupTabHost() {
           mTabHost = getTabHost();
       }
       setupTabHost();
       mTabHost.getTabWidget().setDividerDrawable(se.copernicus.activity.R.drawable.tab_divider);
       setupTab(new TextView(this), getString(R.string.month));
       setupTab(new TextView(this), getString(R.string.week));
       setupTab(new TextView(this), getString(R.string.day));
       setupTab(new TextView(this), getString(R.string.today));
       mTabHost.setCurrentTabByTag(getString(R.string.month));
  
       private void setupTab(final View view, final String tag) {
           View tabview = createTabView(mTabHost.getContext(), tag);
           if (tag.compareTo(getString(R.string.month)) == 0) {
                Intent intent = new Intent(getApplicationContext(), MonthActivity.class);
                TabSpec setContent = mTabHost.newTabSpec(getString(R.string.month)).
                setIndicator(tabview).setContent(new TabHost.TabContentFactory() {
                     public View createTabContent(String tag) {
                          return view;
                     }
                });
                setContent.setContent(intent);
                mTabHost.addTab(setContent);
           }
           if (tag.compareTo(getString(R.string.week)) == 0) {
                Intent intent = new Intent(getApplicationContext(), WeekActivity.class);
                TabSpec setContent = mTabHost.newTabSpec(getString(R.string.week)).
                setIndicator(tabview).setContent(new TabHost.TabContentFactory() {
                     public View createTabContent(String tag) {
                          return view;
                     }
                });
                setContent.setContent(intent);
                mTabHost.addTab(setContent);
           }
           if (tag.compareTo(getString(R.string.day)) == 0) {
                Intent intent = new Intent(getApplicationContext(), DayActivity.class);
                TabSpec setContent = mTabHost.newTabSpec(getString(R.string.day)).
                setIndicator(tabview).setContent(new TabHost.TabContentFactory() {
                     public View createTabContent(String tag) {
                          return view;
                     }
                });
                setContent.setContent(intent);
                mTabHost.addTab(setContent);
           }
           if (tag.compareTo(getString(R.string.today)) == 0) {
                Intent intent = new Intent(getApplicationContext(), DayActivity.class);
                TabSpec setContent = mTabHost.newTabSpec(getString(R.string.today)).
                setIndicator(tabview).setContent(new TabHost.TabContentFactory() {
                     public View createTabContent(String tag) {
                          return view;
                     }
                });
                setContent.setContent(intent);
                mTabHost.addTab(setContent);
           }
       }
  
       private static View createTabView(final Context context, final String text) {
                View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
                TextView tv = (TextView) view.findViewById(R.id.tabsText);
                tv.setText(text);
                return view;
       }
   }
  </code></pre>