title: Show a progress dialog in android tab layout
body: <p>I need to show a progress dialog, while clicking a tab, </p>
  
  <p>My code id </p>
  
  <pre><code>public class SIPTabWidget extends TabActivity{
   Intent intent;
    @Override
      protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  
  
      setContentView(R.layout.main);
  
  
  
      final Resources res = getResources(); // Resource object to get Drawables
      final TabHost tabHost = getTabHost(); // The activity TabHost
      TabHost.TabSpec spec; // Reusable TabSpec for each tab
  
  
  
      // Create an Intent to launch an Activity for the tab (to be reused)
      intent = new Intent().setClass(this, ListContacts.class);
  
      // Initialize a TabSpec for each tab and add it to the TabHost
      spec = tabHost
      .newTabSpec("contacts")
      .setIndicator("",
          res.getDrawable(R.drawable.tab_contacts))
          .setContent(intent);
  
  
  
      tabHost.addTab(spec);
  
      intent = new Intent().setClass(this, Dialer.class);
      spec = tabHost
      .newTabSpec("dialer")
      .setIndicator("", res.getDrawable(R.drawable.tab_dial))
      .setContent(intent);
      tabHost.addTab(spec);
  
  
      intent = new Intent().setClass(this, Favorites.class);
      spec = tabHost
      .newTabSpec("favorites")
      .setIndicator("", res.getDrawable(R.drawable.tab_favorites))
      .setContent(intent);
      tabHost.addTab(spec);
  
      intent = new Intent().setClass(this, org.sipdroid.sipua.ui.Settings.class);
      spec = tabHost
      .newTabSpec("settings")
      .setIndicator("", res.getDrawable(R.drawable.tab_settings))
      .setContent(intent);
  
      tabHost.addTab(spec);
  
  }
  </code></pre>
  
  <p>when i click the settings tab, Setting activity is called, in its oncreate i gave</p>
  
  <pre><code>final ProgressDialog dialog = ProgressDialog.show(getParent(), "Please wait..", "Doing stuff..", true);
          dialog.setCancelable(false);
          dialog.show();
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/PE5V1.jpg" alt="enter image description here"></p>
  
  <p>for me before showing the Settings layout its taking some time to load the layout, so before that i need to show the ProgressDialog, means the time <strong>when i click the Settings tab</strong> and i need to dismiss the Dialog when the tab changes to Settings </p>
  
  <pre><code>tabHost.setOnTabChangedListener(new OnTabChangeListener() {
  
          @Override
          public void onTabChanged(String tabId) {
          System.out.println(" Tab ID:  "+tabId);
  if(tabId.equals("dial")){
  dialog .dismiss();
  }
  
      }
  });
  </code></pre>
  
  <p>Settings.class</p>
  
  <pre><code>public class Settings extends PreferenceActivity implements OnSharedPreferenceChangeListener, OnClickListener {
  
  @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          System.out.println("Settings oncreate");
          final ProgressDialog dialog = ProgressDialog.show(getParent(), "Please  wait..", "Doing stuff..", true);
          handler = new Handler() {
  
                @Override
                public void handleMessage(Message msg) {
                dialog.dismiss();
  
                }
             };
  
  
             Thread t = new Thread() {
                  public void run() {
                      //send message
                  handler.sendEmptyMessage(0);      
                  }
              };  
  
  
  
  
  
         if (Receiver.mContext == null) Receiver.mContext = this;
          addPreferencesFromResource(R.xml.preferences);
          setDefaultValues();
          Codecs.check();
          t.start
  
  
  
  
  
      }
  </code></pre>