Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.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
选项卡活动折旧后,如何在android中使用选项卡?使用fragment时,我遇到了一个问题_Android_Tabs_Android Actionbar_Actionbarsherlock_Tabactivity - Fatal编程技术网

选项卡活动折旧后,如何在android中使用选项卡?使用fragment时,我遇到了一个问题

选项卡活动折旧后,如何在android中使用选项卡?使用fragment时,我遇到了一个问题,android,tabs,android-actionbar,actionbarsherlock,tabactivity,Android,Tabs,Android Actionbar,Actionbarsherlock,Tabactivity,选项卡活动折旧后,如何在android中使用选项卡?通过使用sherlock和fragments,我可以进行制表,但我希望将制表符图像设置为整体,而不是制表符图标。。。 我不需要我的图像黑色背景我希望我的整个标签上的图像。 这是我的密码 private FragmentTabHost mTabHost; mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); // mTabHost.setup

选项卡活动折旧后,如何在android中使用选项卡?通过使用sherlock和fragments,我可以进行制表,但我希望将制表符图像设置为整体,而不是制表符图标。。。 我不需要我的图像黑色背景我希望我的整个标签上的图像。 这是我的密码

private FragmentTabHost mTabHost;
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
           // mTabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);
            mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);

            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1").setIndicator("",
                            getResources().getDrawable(R.drawable.tab8)),
                    FragmentTab.class, null);
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2").setIndicator("Tab 2",
                            getResources().getDrawable(R.drawable.tab9)),
                    FragmentTab.class, null);
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab3").setIndicator("Tab 3",
                            getResources().getDrawable(android.R.drawable.star_on)),
                    FragmentTab.class, null);
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab4").setIndicator("Tab 4",
                            getResources().getDrawable(android.R.drawable.star_on)),
                    FragmentTab.class, null);

Help Required :)

您可以使用ActionBar.Tab上的setCustomView()完全自定义ActionBar选项卡。您将为选项卡定义XML布局,然后将其设置为类似:

// Home tab
ActionBar.Tab tabHome = mActionBar.newTab();
tabHome.setText("Home");        
LinearLayout layoutLinear = (LinearLayout)inflater.inflate(R.layout.layout_tab_standard, null);
TextView title = (TextView)layoutLinear.findViewById(R.id.title);
title.setText(strTabTitle);
tabHome.setCustomView(layoutLinear);
mActionBar.addTab(tabHome);
因此,您可以在定义的线性布局(本例中为R.layout.layout_tab_standard)上放置ImageView或设置可绘制的背景


您还应该查看操作栏样式生成器(),您可能会发现这很有用。

我使用了tabhost,您可以使用tabhost而不使用tabactivity以下是代码

final TabHost tabHost=(TabHost)findViewById(R.id.tabhost);
    tabHost.setup();

        final TabSpec spec1 = tabHost.newTabSpec("Tab1");
        View view = LayoutInflater.from(this).inflate(R.layout.tabbar8, tabHost.getTabWidget(), false);
        spec1.setIndicator(view);
        spec1.setContent(R.id.tab1);
其中tabbar8是我想在第一个选项卡上设置的布局

您也可以调用mActionBar.addTab()方法上的setIcon()来设置选项卡指示器上的可绘制图标。