Why is Android TabHost stealing focus from a TextView?

Well, definitly a bug : http://code.google.com/p/android/issues/detail?id=2516.

Hope it will be fixed in the next release because this is a really anoying issues for complex apps with an advanced layout.


I was facing the same kind of issue with HoneyComb but found a very simple solution. So I thought it can be helpful for someone to share my experience. Everytime when a tab is clicked, the focus is on Edit Text and you can actually type with hard keyboard but soft keyboard never pops up. Even with below code, it didnt solve the issue:

input1.requestFocusFromTouch();
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(input1, InputMethodManager.SHOW_FORCED);

Solution: In the main class where you are handling Tabs, just write below Java code:

myTabHost.setOnTabChangedListener(new OnTabChangeListener(){    
    public void onTabChanged(String tabID) {    
        myTabHost.clearFocus(); 
    }   
}); 

Tags:

Android

Focus