Q:

Set action bar title corresponding to ActionBar tab title

When the active tab in my app is changed and an other tab gets the active tab, I would like the ActionBar title to be set to a certain text. How can I do that?
Thanks

A:

Have your Activity implement the ActionBar.TabListener interface:
class MainActivity extends Activity implements ActionBar.TabListener{

    ...
    ...

    @Override
    onTabSelected(ActionBar.Tab tab, FragmentTransaction ft){
        setTitle(tab.getText().toString());
    }

    @Override
    onTabReselected(ActionBar.Tab tab, FragmentTransaction ft){}

    @Override
    onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft){}

}

And voila! It works! There you go :)

