set tab icon instead of text using tabA.setIcon(R.drawable.your_image_name)
For Custom Tab Views:
tab_one.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/tab_one_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_image/icon_name" />
<TextView
android:id="@+id/tab_one_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="your_text_here" />
</LinearLayout>
Create method in your code like this:
public void createTab(int view) {
ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setTabListener(this);
tab.setCustomView(view);
getSupportActionBar().addTab(tab);
}
and then call you method in onCreate like this, for each tab:
createTab(R.layout.tab_one);
Tested Code:
So I just tested this code and it works for me!
I have this at top:
ActionBar mActionBar;
Tab tab;
And in onCreate, I have this:
tab = mActionBar.newTab();
tab.setCustomView(R.layout.tab_one);
tab.setTabListener(tabListener);
mActionBar.addTab(tab);
and this is how my tab_one.xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/tab_one_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_tab_icon" />
<TextView
android:id="@+id/tab_one_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab Text" />
</LinearLayout>