Reputation: 279
I want to add badge to my TabLayout
. When each add new element (item ListView
) in database I want to show a Badge ( +1 ) in order to inform the user about each new.
Like this image :
Any help would be appreciated
Upvotes: 1
Views: 4429
Reputation: 21766
custom view
for each TAB
.custom view
to each TAB
by using TAB.setCustomView(custom_View)Try this:
// Tab
Tab tab = YourTabLayout.getTabAt(position);
// Get Custom view using LayoutInflater
// ...........
// Set custom view
tab.setCustomView(custom_View);
Upvotes: 3
Reputation: 2795
You will need to add a custom View
to each tab.
so once you have your ViewPager
and Adapter
all set up.
Iterate over the tabs and add custom views.
something like:
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
tab.setCustomView(createCustomViewForTab(i);
}
Upvotes: 0