2015-07-11 37 views
-1

我需要在選項卡中顯示通知的數量。我如何在android中做到這一點。我的標籤代碼如下所示。如何在tabhost中添加徽章計數器android

mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost); 
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent); 

    mTabHost.addTab(mTabHost.newTabSpec("HOME").setIndicator("HOME"), 
      homepage.class, null); 
    mTabHost.addTab(mTabHost.newTabSpec("NOTIFICATIONS").setIndicator("NOTIFICATIONS"), 
      notificationfragment.class, null); 
    return rootView; 

回答

0

您可以通過設置視圖定製tabhosts規格上AS-

spec = tabHost.newTabSpec("groups"); 
    View view = LayoutInflater.from(this).inflate(R.layout.tabwidget_tabs, tabHost.getTabWidget(), false); 
    spec.setIndicator(view); 
+0

應該是什麼那裏R.layout.tabwidget_tabs? – user1455450

+0

這是tabItem的佈局。 –

+0

View view = LayoutInflater.from(getApplicationContext())。inflate(R.layout.tab_layout,null); TextView tv_counter =(TextView)view.findViewById(R.id.tab_counter); BadgeView badge = new BadgeView(this,tv_counter); badge.setText(「6」); badge.show();這是我必須在標籤中顯示徽章的代碼。我如何更新其他課程的徽章? – user1455450

相關問題