You can create a custom Tab item xml and put a RelativeLayout with a background image and a centerInParent textView. Set RelativeLayout's visibility to GONE and whenever you want to show it, make it visible and set that textview to any text you want to.
<RelativeLayout
android:id="@+id/tabBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="47dp"
android:layout_marginTop="10dp"
android:layout_toStartOf="@+id/tabTitle"
android:visibility="gone" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/basket_item"
android:contentDescription="@string/action_settings" />
<TextView
android:layout_centerInParent="true"
android:id="@+id/tabBadgeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="10sp" />
</RelativeLayout>
Also make sure to set that Relativelayout in your code while you are generating your tag like the code below so you can access to it whenever you want to:
// mTitle is the title of the tab
if (mTitle.equalsIgnoreCase("Basket")) {
//count is the TextView inside your badge
count = (TextView) view.findViewById(R.id.tabBadgeText);
//layout is the whole badge's layout
layout = (RelativeLayout) view.findViewById(R.id.tabBadge);
}
Hope it helps, if you need more information please feel free to ask.