guness
guness

Reputation: 6656

when tab is changed, which method is called besides onTabChange

I have a tabhost and several tabs inside. each tab is an activity. When I change tab, is there any method for tabs to be called like onCreate(), onRestart(), onResume(). by the wasy I dont want to set ontabchangedlistener to tabhost. PS: version api8

edit: moreover is there any of them called when a tab disactivated (some other tab comes to screen)

Upvotes: 0

Views: 685

Answers (1)

Urho
Urho

Reputation: 2302

Not by default, but if you don't want to use OnTabChangedListener, you can set OnTouchListener to each of the tabs:

for(int i=0;i<tabWidget.getTabCount();i++) {
    tabWidget.getChildAt(i).setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) { 
             //do things 
             return false; 
        } 
    }); 

}

Upvotes: 1

Related Questions