Action Bar

Action Bar:
*The Action Bar is a window feature.
*This feature must be requested before setting a content view.
*By default it is automatically set by your Activity's.

Two Ways Of Adding or Removing this Action Bar:
Through Manifest. As we know that by Default Activity has this Theme, if you want To remove this then add this line
in the activity tag android:theme="@android:style/Theme.NoTitleBar"
[[note]] If you don't want this action bar in your application then add these in application tag android:theme="@android:style/Theme.NoTitleBar" [[/note]]

Through Java. As we Know this is Action bar is the window feature, so when you want to set or remove it should be done before setting contentview.
We need to add these line in the oncreate() before setting contentview getWindow().requestFeature(Window.FEATURE_NO_TITLE);
we have many paraments which can set to requestFeature(). like Window_ACTION_BAR_OVERLAY.

Action Bar Tabs:
A TabListener receives event callbacks from the action bar as tabs are deselected, selected, and reselected.
A FragmentTransaction is provided to each of these callbacks;
If any operations are added to it, it will be committed at the end of the full tab switch operation.

We do with simple Action bar tabs with Fragments.

Take a normal activity, take a simple layout and take a button in that.
Next we ll take that button and write onclickListner to it. and in that i ll write the code to add tabs.

//First get the Action bar object.
ActionBar bar = getActionBar();

//we can get the count of tabs.
int tabCount = bar.getTabCount();
(note The tab will be added at the end of the list. If this is the first tab to be added it will become the selected tab)).

Next if we want to add tabs then we need to register that.
bar.addTab(bar.newTab().setText(text).setTabListener(new TabListener(new TabContentFragment(text))));
bar.newTab()..adding a new tab.
setText(text)..setting text to that tab.
setTabListener(new TabListener())..setting the tablistner(we ll see how wirte that tablistner).
//new TabContentFragment(text).. in this i am adding one fragment to one tab(you can add your own views).

Now we ll see how to implement this tablistner class and its methods.

class TabListener implements ActionBar.TabListener{

In this we need to implement the overridden methods like.

//these method are call back method it is called automatically when we click on the tab. just we need to write our code in the method actually what //we want to do when that is clicked.

//ontabselected when we click on the tab.
onTabSelected(Tab tab, FragmentTransaction ft).

//these is like in idol state
onTabUnselected(Tab tab, FragmentTransaction ft)

//these called when the user selected one tab and if we again press same tab then these method is called
onTabReselected(Tab tab, FragmentTransaction ft)