gt:         TextView title = (TextView) findViewById(R.id.window_title);
context: /*
   * Mobile - Android, User Interface for the GLIMMPSE Software System.  Allows
   * users to perform power and sample size calculations. 
   * 
   * Copyright (C) 2010 Regents of the University of Colorado.  
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   */
  package edu.ucdenver.bios.glimmpseandroid.activity;
  
  import org.restlet.representation.Representation;
  import org.restlet.resource.ClientResource;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.res.Resources;
  import android.graphics.drawable.Drawable;
  import android.net.ConnectivityManager;
  import android.net.wifi.WifiManager;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Message;
  import android.text.method.LinkMovementMethod;
  import android.text.method.ScrollingMovementMethod;
  import android.util.DisplayMetrics;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.Window;
  import android.widget.Button;
  import android.widget.ListView;
  import android.widget.TabHost;
  import android.widget.TabHost.OnTabChangeListener;
  import android.widget.TabHost.TabContentFactory;
  import android.widget.TextView;
  import android.widget.Toast;
  import edu.ucdenver.bios.glimmpseandroid.R;
  import edu.ucdenver.bios.glimmpseandroid.activity.design.ResultsActivity;
  import edu.ucdenver.bios.glimmpseandroid.adapter.DesignListAdapter;
  import edu.ucdenver.bios.glimmpseandroid.adapter.TutorialAdapter;
  import edu.ucdenver.bios.glimmpseandroid.application.StuyDesignContext;
  import edu.ucdenver.bios.webservice.common.domain.StudyDesign;
  
  // TODO: Auto-generated Javadoc
  /**
   * The Class TabViewActivity deals with 'Tutorial', 'Design' and 'About Us'
   * screens of the GLIMMPSE LITE Application.
   * 
   * @author Uttara Sakhadeo
   * @version 1.0.0
   */
  public class TabViewActivity extends Activity implements Runnable,
          TabContentFactory {
  
      public String exceptionMessage = null;
  
      /** The Constant SERVICE_URL. */
      private static final String SERVICE_URL = "http://glimmpse.samplesizeshop.org/power/";
  
      /** The Constant FEEDBACK_ADDRESS. */
      private static final String FEEDBACK_ADDRESS = "samplesizeshop@gmail.com";
  
      /** The Constant TAB_ID. */
      public static final String TAB_ID = "tab_id";
  
      /** The Constant TAB_HEIGHT. */
      public static final int TAB_HEIGHT = 50;
  
      /** The Constant WIFI_AVAILABLE. */
      public static final int WIFI_AVAILABLE = 1;
  
      /** The Constant MOBILE_NETWORK_AVAILABLE. */
      public static final int MOBILE_NETWORK_AVAILABLE = 2;
  
      /** The Constant TUTORIAL_TAB. */
      public static final int TUTORIAL_TAB = 0;
  
      /** The Constant DESIGN_TAB. */
      public static final int DESIGN_TAB = 1;
  
      /** The Constant ABOUT_US_TAB. */
      public static final int ABOUT_US_TAB = 2;
  
      /** The labels. */
      String[] labels;
  
      /** The calculate button. */
      private Button calculateButton;
  
      /** The reset button. */
      private Button resetButton;
  
      /** The resources. */
      private Resources resources;
  
      /** The tutorial list view. */
      private ListView tutorialListView;
  
      /** The design list view. */
      private ListView designListView;
  
      /** The m tab host. */
      private TabHost mTabHost;
  
      /** The tab one content view. */
      private View tabOneContentView;
  
      /** The tab two content view. */
      private View tabTwoContentView;
  
      /** The tab three content view. */
      private View tabThreeContentView;
  
      /** The global variables. */
      StuyDesignContext globalVariables;
  
      /** The NE t_ connection. */
      private boolean NET_CONNECTION = false;
  
      /** The json str. */
      private String jsonStr;
  
      /** The handler. */
      private static Handler handler;
  
      /** The progress. */
      private ProgressDialog progressDialog;
  
      /** The context. */
      private Context context;
  
      /*
       * (non-Javadoc)
       * 
       * @see android.app.Activity#onResume()
       */
      protected void onResume() {
          super.onResume();
          if (mTabHost.getCurrentTab() == DESIGN_TAB) {
              designListPopulate();
              globalVariables = StuyDesignContext.getInstance();
              int progress = globalVariables.getTotalProgress();
              if (progress == 6) {
                  calculateButtonEnabled();
              }
          } else if (mTabHost.getCurrentTab() == ABOUT_US_TAB) {
              aboutUsPopulate();
              for (int i = TUTORIAL_TAB; i <= ABOUT_US_TAB; i++) {
                  mTabHost.setCurrentTab(i);
              }
          }
      }
  
      /**
       * This method is called by Android when the Activity is first started. From
       * the incoming Intent, it determines what kind of editing is desired, and
       * then does it.
       * 
       * @param savedInstanceState
       *            the saved instance state
       */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // set the view for the activity
  
          final Window window = getWindow();
          boolean useTitleFeature = false;
  
          context = TabViewActivity.this;
  
          resources = getResources();
  
          progressDialog = new ProgressDialog(this);
          progressDialog.setTitle(resources
                  .getString(R.string.progress_dialog_title));
          progressDialog.setMessage(resources
                  .getString(R.string.progress_dialog_message));
          progressDialog.setCancelable(false);
          progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  
          handler = new Handler() {
  
              @Override
              public void handleMessage(Message msg) {
                  progressDialog.dismiss();
                  if (jsonStr != null && !jsonStr.isEmpty()) {
                      Bundle bundle = new Bundle();
                      bundle.putString("results", jsonStr);
                      Intent intent = new Intent(context, ResultsActivity.class);
                      intent.putExtras(bundle);
                      startActivity(intent);
                      jsonStr = null;
                      NET_CONNECTION = false;
                  } else if (!NET_CONNECTION) {
  
                      AlertDialog.Builder builder = new AlertDialog.Builder(
                              context);
                      builder.setTitle(resources
                              .getString(R.string.no_net_connection_title));
                      builder.setMessage(
                              resources
                                      .getString(R.string.no_net_connection_description))
                              .setCancelable(false)
                              .setPositiveButton(
                                      resources.getString(R.string.ok),
                                      new DialogInterface.OnClickListener() {
                                          public void onClick(
                                                  DialogInterface dialog, int id) {
  
                                          }
                                      });
                      builder.show();
                  } else {
                      AlertDialog.Builder builder = new AlertDialog.Builder(
                              context);
                      builder.setTitle(resources
                              .getString(R.string.calculation_error_title));
                      builder.setMessage(
                              resources
                                      .getString(R.string.calculation_error_description)
                                      + " " + exceptionMessage)
                              .setCancelable(false)
                              .setPositiveButton(
                                      resources.getString(R.string.ok),
                                      new DialogInterface.OnClickListener() {
                                          public void onClick(
                                                  DialogInterface dialog, int id) {
  
                                          }
                                      });
                      builder.show();
                  }
                  super.handleMessage(msg);
              }
  
          };
  
          // If the window has a container, then we are not free
          // to request window features.
          if (window.getContainer() == null) {
              useTitleFeature = window
                      .requestFeature(Window.FEATURE_CUSTOM_TITLE);
          }
          setContentView(R.layout.main);
  
          if (useTitleFeature) {
              window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
          }
  
          labels = resources.getStringArray(R.array.tab_labels);
  
          Button homeButton = (Button) findViewById(R.id.home_button);
          homeButton.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  finish();
              }
          });
  
          globalVariables = StuyDesignContext.getInstance();
          setupViews();
          // setup Views for each tab
  
          // call method to set up tabs
          mTabHost = (TabHost) findViewById(android.R.id.tabhost);
          mTabHost.setup();
          mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
  
          // setup each individual tab
          setupTab(labels[TUTORIAL_TAB]);
          setupTab(labels[DESIGN_TAB]);
          setupTab(labels[ABOUT_US_TAB]);
          setTabHeight(TAB_HEIGHT);
  
  