amp
amp

Reputation: 12352

Fire onTabChanged() programmatically

If I have a listener for changed tab like this:

        mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

        public void onTabChanged(String tabId) {

            if (mTabHost.getCurrentTab() == 0) {
                 //..
            }
            else if (mTabHost.getCurrentTab() == 1) {
                 //..
            }
            else if (mTabHost.getCurrentTab() == 2) {
                 //..
            }
        }
    });

How can I fire the onTabChanged() method programmatically?

Upvotes: 0

Views: 1244

Answers (1)

Jeffrey Blattman
Jeffrey Blattman

Reputation: 22637

Just call,

mTabHost.setCurrentTab(id);

Or

mTabHost.setCurrentTabByTag(tag);

For reference,

http://developer.android.com/reference/android/widget/TabHost.html

Upvotes: 3

Related Questions