how to update badge value on tab in Android?
android, tabs, tabwidget
Solution
create static `TabWidget` object tab in `TabActivity` like this,
public static TabWidget tabs;
Access the `tabs` object from any activity after your operations performs, update your `balance` in `SharedPreferences`. and use following code snippet.
In your other `Activity`.
TabWidget tabs = TabActivity.tabs;
badge = new BadgeView(context, tabs, 3);
badge.setTextSize(12);
badge.setBadgePosition(BadgeView.POSITION_TOP_RIGHT);
badge.setText(pref.getString("balance", "0"));
badge.toggle();
Hope this will help you.
Problem
I have `tabbar` with 5 tabs and i have added badge on my 4th tab. i want to update my badge value after some operation perform with the server. but don't know how can do this. Also i want update badge value from different `activities`. snippet of code adding badge on `Tabbar` ``` TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs); badge = new BadgeView(context, tabs, 3); badge.setTextSize(12); badge.setBadgePosition(BadgeView.POSITION_TOP_RIGHT); badge.setText(pref.getString("balance", "0")); badge.toggle(); ``` Thank you in Advance