Look at my answer here for widgets/app.

You can use shapecount.xml

res/layout/tabicon.xml

<RelativeLayout
   
android:orientation="vertical"
   
android:background="@null"
   
android:id="@+id/rlayout"
   
android:layout_width="wrap_content"
   
android:layout_height="wrap_content" >
    <ImageView
            android:id="@+id/icon"
            android:src="@android:drawable/ic_menu_mylocation"
<!-- Just for test -->
            android:layout_margin="0dp"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>

   
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
       
android:text="50" android:textSize="12dp" android:textStyle="bold"  
       
android:background="@drawable/shapecount"
       
android:textColor="#FFFFFF"
       
android:paddingLeft="3dp" android:paddingRight="3dp"
           
android:layout_margin="0dp"
       
android:layout_alignBottom="@+id/rlayout"
       
android:id="@+id/txtCount" />

</RelativeLayout>

When creating your tab:

LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.tabicon, null);
final TextView txtCount = (TextView) view.findViewById(R.id.txtCount);

spec
= tabHost.newTabSpec("artists").setIndicator(view).setContent(intent);

Now you can use txtCount to update the number in the tab's icon. See the post I pointed out above for an example of TimerTask to test this.

You will have to arrange the layout as you wish also

'Android > Tip&Tech' 카테고리의 다른 글

루팅폰 확인하기  (0) 2011.06.23
camera intent 관련 flag 팁  (0) 2011.06.21
[팁] Android에서 SAX를 이용한 Parsing 방법  (0) 2011.06.20
[android]listView 항목 드래그앤드랍 하기  (0) 2011.06.20
stateListDrawable  (0) 2011.06.17

+ Recent posts