title: Why is Android TabHost stealing focus from a TextView?
body: <p>I have an application using the following layout :</p>
  
  <p><a href="http://img15.imageshack.us/img15/238/screenshot003xbo.png" rel="nofollow noreferrer">alt text http://img15.imageshack.us/img15/238/screenshot003xbo.png</a></p>
  
  <p>When the app starts, the focus is on the first TextView, but if you try to type any letter in it, the focus goes directly to the tabs. It seems that I am not the only one <a href="http://groups.google.com/group/android-developers/browse_thread/thread/f3fdd1eb17288886/0d28c51a6b9ffdfe?lnk=gst&amp;q=tab+focus#0d28c51a6b9ffdfe" rel="nofollow noreferrer">fighting with this issue</a>, and maybe this is related to the following:</p>
  
  <p><a href="http://groups.google.com/group/android-developers/browse_thread/thread/435791bbd6c550a/8022183887f38f4f?lnk=gst&amp;q=tabs+focus#8022183887f38f4f" rel="nofollow noreferrer">http://groups.google.com/group/android-developers/browse_thread/thread/435791bbd6c550a/8022183887f38f4f?lnk=gst&amp;q=tabs+focus#8022183887f38f4f</a></p>
  
  <p>Anyway, have you any idea of why that happens? And of course, any workaround would be appreciated.</p>
  
  <hr>
  
  <p>I post the code below to avoid overloading the question :</p>
  
  <p>The XML :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
      &lt;LinearLayout 
            android:padding="5px"
            android:orientation="vertical" 
            android:id="@+id/task_edit_panel"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
             android:layout_weight="50" &gt;
  
          &lt;LinearLayout android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView android:layout_width="wrap_content"
                  android:layout_height="wrap_content" 
                  android:text="@string/title" 
                  android:textStyle="bold" /&gt;
  
              &lt;EditText android:id="@+id/title" 
                android:layout_width="fill_parent"
                  android:layout_height="fill_parent" /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;TabHost android:id="@+id/edit_item_tab_host"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"&gt; 
  
              &lt;TabWidget android:layout_width="fill_parent"
                          android:layout_height="wrap_content" 
                          android:id="@android:id/tabs" /&gt; 
  
              &lt;FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:paddingTop="65px"&gt; &lt;!--  you need that if you don't want the tab content to overflow --&gt; 
  
                &lt;LinearLayout
                     android:id="@+id/edit_item_date_tab"
                     android:orientation="vertical"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:padding="5px" &gt; 
  
                      &lt;TextView android:layout_width="wrap_content"
                              android:layout_height="wrap_content" 
                              android:text="date" 
                               android:textStyle="bold" /&gt;
  
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                     android:id="@+id/edit_item_geocontext_tab"
                     android:orientation="vertical"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:padding="5px" &gt; 
  
                  &lt;TextView android:layout_width="wrap_content"
                              android:layout_height="wrap_content" 
                              android:text="lieu" 
                               android:textStyle="bold" /&gt;
  
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                     android:id="@+id/edit_item_text_tab"
                     android:orientation="vertical"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                       android:padding="5px"&gt; 
  
                  &lt;EditText android:id="@+id/details" 
                          android:layout_width="fill_parent"
                          android:layout_height="fill_parent"
                          android:scrollbars="vertical" /&gt;
  
                  &lt;/LinearLayout&gt;
  
              &lt;/FrameLayout&gt;
  
          &lt;/TabHost&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;!-- Bottom pannel with "add item" button --&gt;
      &lt;LinearLayout 
            android:padding="5px"
            android:orientation="horizontal" 
            android:layout_weight="1"
            android:id="@+id/task_edit_panel"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#E7E7E7" &gt;
  
            &lt;!--  Let the height set to fill_parent until we find a better way for the layout  --&gt;
            &lt;Button android:id="@+id/item_edit_ok_button"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_gravity="bottom"
                  android:text="@string/ok"
                  style="?android:attr/buttonStyleSmall"
                  android:layout_weight="1" /&gt;
  
             &lt;Button android:id="@+id/item_edit_cancel_button"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_gravity="bottom"
                  android:text="@string/cancel"
                  style="?android:attr/buttonStyleSmall"
                  android:layout_weight="1" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And the Java code :</p>
  
  <pre><code>    TabHost tab_host = (TabHost) findViewById(R.id.edit_item_tab_host);
      // don't forget this setup before adding tabs from a tabhost using a xml view or you'll get an nullpointer exception
      tab_host.setup(); 
  
      TabSpec ts1 = tab_host.newTabSpec("TAB_DATE");
      ts1.setIndicator(getString(R.string.when), getResources().getDrawable(R.drawable.ic_dialog_time));
      ts1.setContent(R.id.edit_item_date_tab);
      tab_host.addTab(ts1);
  
      TabSpec ts2 = tab_host.newTabSpec("TAB_GEO");
      ts2.setIndicator(getString(R.string.where),  getResources().getDrawable(R.drawable.ic_dialog_map));
      ts2.setContent(R.id.edit_item_geocontext_tab);
      tab_host.addTab(ts2);
  
      TabSpec ts3 = tab_host.newTabSpec("TAB_TEXT");
      ts3.setIndicator(getString(R.string.what),  getResources().getDrawable(R.drawable.ic_menu_edit));
      ts3.setContent(R.id.edit_item_text_tab);
      tab_host.addTab(ts3);
  
      tab_host.setCurrentTab(0);
  </code></pre>