title: EditText losing focus using hard keyboard when TabHost is present in activity
body: <p>I am displaying an EditText inside tabhost. Tabhost is inside a SherlockFragmentActivity.</p>
  
  <p>Suppose I am in touch mode and I click on EditText to give it focus and start typing on it. After typing 2-3 chars, I decided to use my hard keyboard. As soon as press first hard key, I move out of touch mode and this also causes the focus to moves back to the currently selected tab. As long as I do not use hard navigation keys to bring back the focus to my EditText, I will not be able to type into EditText.</p>
  
  <p>This issue is caused only when TabHost is not inside TabActivity.</p>
  
  <p>A quick sample code to reproduce this problem could be - FragmentTabs activity of ActionBarSherlock sample code. Select CustomTab and try to type any text inside the search view in action bar using the hard keyboard. See focus simply moves to tab.</p>
  
  <p>Problem is reproducible on android 2.2, 4.0 and using ICS emulator as well.</p>
  
  <p>Does anyone have more info. about this issue?</p>
  
  <p>(A workaround seems to be mentioned here: <a href="https://stackoverflow.com/a/8684025/333137">https://stackoverflow.com/a/8684025/333137</a> but it looks like a hack)</p>
  
  <p>Thanks.</p>
  
  <p>Edit: Upon more investigation, 
  I found setup() function inside TabHost class which needs to be called only if TabHost is not used inside TabActivity.
  It registers a key listener which receives callback only when hard key is pressed. </p>
  
  <pre><code>void setup(){
         // KeyListener to attach to all tabs. Detects non-navigation keys
          // and relays them to the tab content.
          mTabKeyListener = new OnKeyListener() {
              public boolean onKey(View v, int keyCode, KeyEvent event) {
                  switch (keyCode) {
                      case KeyEvent.KEYCODE_DPAD_CENTER:
                      case KeyEvent.KEYCODE_DPAD_LEFT:
                      case KeyEvent.KEYCODE_DPAD_RIGHT:
                      case KeyEvent.KEYCODE_DPAD_UP:
                      case KeyEvent.KEYCODE_DPAD_DOWN:
                      case KeyEvent.KEYCODE_ENTER:
                          return false;
  
                  }
                  **mTabContent.requestFocus(View.FOCUS_FORWARD);**
                  return mTabContent.dispatchKeyEvent(event);
              }
  </code></pre>
  
  <p>I am not sure why it is calling requestFocus(View.FOCUS_FORWARD) but this does not set the focus to EditText inside it (which it should?). Also, in case of search view in action bar, it is totally outside tab.</p>