Android: TabHost is stealing focus from a EditText


I am recently working on Android app development and had an issue with TabHost and EditText inside that TabHost. 

somehow, when I was trying to insert a value in that EditText, focus was set automatically on tab and was not able to type anything. 

Tried hard to google and came to know that its a bug and Good team is working on it as of today. But there is a workaround for this problem as below – 

 

txtDescription = (EditText) V.findViewById(R.id.txtAttactmentDescription);
txtDescription.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
txtDescription.requestFocusFromTouch();
return false;
}
});

Advertisements

8 thoughts on “Android: TabHost is stealing focus from a EditText

  1. Or you can remove OnTouchModeChangeListener of the Tabhost:
    TabHost mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

    @Override
    public void onViewDetachedFromWindow(View v) {}

    @Override
    public void onViewAttachedToWindow(View v) {
    mTabHost.getViewTreeObserver().removeOnTouchModeChangeListener(mTabHost);
    }
    });

    Source: https://code.google.com/p/android/issues/detail?id=2516

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s