title: Application Crashes every time I run this code
body: <p>Every time i run this code, the app crashes, does anyone know why is this happening. I would really appreciate. Thanks in advance!  The code is quite simple though, I am trying to add a new tab and every time i click a certain button and remove the tab on choosing the current tab.</p>
  
  <pre><code>public class MainActivity extends Activity implements OnTabChangeListener {
      TabHost tabs;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      setContentView(R.layout.activity_main);
  
          tabs=(TabHost)findViewById(R.id.tabhost);
      tabs.setup();
  
  
      TabHost.TabSpec spec= tabs.newTabSpec("buttontab");
      spec.setContent(R.id.buttontab);
      spec.setIndicator("Button");
      tabs.setCurrentTab(0);
      tabs.setOnTabChangedListener(this);
  
      Button btn=(Button)tabs.getCurrentView().findViewById(R.id.buttontab);
              btn.setOnClickListener(new View.OnClickListener() { 
  public void onClick(View view) {
      TabHost.TabSpec spec=tabs.newTabSpec("tag1");
  
      spec.setContent(new TabHost.TabContentFactory() {
          public View createTabContent(String tag) {
              return(new AnalogClock(MainActivity.this));
          }
      });
      spec.setIndicator("Clock");
      tabs.addTab(spec);
  
  
      //tabs.getTabWidget().removeView(tabs.getTabWidget().getChildTabViewAt(3));
  
      }
          });
  
  
    }
  @Override
  public void onTabChanged(String arg0) {
      // TODO Auto-generated method stub
      int currentTabNumber = tabs.getCurrentTab();
  
  Toast.makeText(getBaseContext(), "current tab:" +        
  currentTabNumber,Toast.LENGTH_SHORT).show();                  
  //Toast.makeText(getBaseContext(), Counts, Toast.LENGTH_SHORT).show();
  tabs.getTabWidget().removeView(tabs.getTabWidget().getChildTabViewAt(currentTabNumbe    r));
  
  }
  }
  </code></pre>