Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在tabhost android中添加徽章计数器_Android_Android Layout_Android Fragments_Android Activity - Fatal编程技术网

如何在tabhost android中添加徽章计数器

如何在tabhost android中添加徽章计数器,android,android-layout,android-fragments,android-activity,Android,Android Layout,Android Fragments,Android Activity,我需要在选项卡中显示通知的数量。我如何在安卓系统中做到这一点。我的选项卡代码如下所示 mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost); mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent); mTabHost.addTab(mTabHost.newTabSpec("HOME"

我需要在选项卡中显示通知的数量。我如何在安卓系统中做到这一点。我的选项卡代码如下所示

    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;

通过将tabhosts规范上的视图设置为-

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

R.layout.tabwidget\u tabs中应该有什么?这是tabItem.View=LayoutInflater.from(getApplicationContext())的布局。充气(R.layout.tab\u layout,null);TextView tv_计数器=(TextView)view.findViewById(R.id.tab_计数器);BadgeView badge=新的BadgeView(此,电视台);徽章.setText(“6”);徽章显示();这是我必须在选项卡中显示徽章的代码。如何从其他类更新徽章?