当前位置: 首页>>代码示例>>Java>>正文


Java TabHost.TabSpec方法代码示例

本文整理汇总了Java中android.widget.TabHost.TabSpec方法的典型用法代码示例。如果您正苦于以下问题:Java TabHost.TabSpec方法的具体用法?Java TabHost.TabSpec怎么用?Java TabHost.TabSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TabHost的用法示例。


在下文中一共展示了TabHost.TabSpec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
public final void addTab(final TabHost.TabSpec tabSpec,
		final Class<?> clss, final Bundle args) {
	tabSpec.setContent(new DummyTabFactory(mContext));
	String tag = tabSpec.getTag();

	TabInfo info = new TabInfo(tag, clss, args);

	if (mAttached) {
		// If we are already attached to the window, then check to make
		// sure this tab's fragment is inactive if it exists. This shouldn't
		// normally happen.
		info.fragment = mFragmentManager.findFragmentByTag(tag);
		if (info.fragment != null && !info.fragment.isDetached()) {
			FragmentTransaction ft = mFragmentManager.beginTransaction();
			ft.detach(info.fragment);
			ft.commit();
		}
	}

	mTabs.add(info);
	addTab(tabSpec);
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:23,代码来源:FixedFragmentTabHost.java

示例2: createRotateTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void createRotateTab(final LayoutInflater inflater, final ViewGroup container, final SeekBar.OnSeekBarChangeListener listener) {
    TabHost.TabSpec spec;

    spec = mTabHost.newTabSpec(getString(R.string.rotate_tab));
    spec.setIndicator(createTabView(inflater, container, getString(R.string.rotate_title)));

    spec.setContent(new TabHost.TabContentFactory() {

        @Override
        public View createTabContent(String tag) {

            View view = inflater.inflate(R.layout.fragment_rotate, container, false);

            mRotateSeekBar = (RangeSeekBar) view.findViewById(R.id.rotate_seekBar);
            mRotateSeekBar.setRange(getResources().getIntArray(R.array.angle_seekbar_values));
            mRotateSeekBar.setOnSeekBarChangeListener(listener);

            return (view);

        }
    });
    mTabHost.addTab(spec);
}
 
开发者ID:hollaus,项目名称:TinyPlanetMaker,代码行数:24,代码来源:TabFragment.java

示例3: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void addTab(final TabHost host, final int categoryId) {
    final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
    final TabHost.TabSpec tspec = host.newTabSpec(tabId);
    tspec.setContent(R.id.emoji_keyboard_dummy);
    final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
            R.layout.emoji_keyboard_tab_icon, null);
    // TODO: Replace background color with its own setting rather than using the
    //       category page indicator background as a workaround.
    iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
    iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
    iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
    tspec.setIndicator(iconView);
    host.addTab(tspec);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:15,代码来源:EmojiPalettesView.java

示例4: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
private static void addTab(MFBMain activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    String tag = tabSpec.getTag();

    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
    if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        ft.detach(tabInfo.fragment);
        ft.commit();
        activity.getSupportFragmentManager().executePendingTransactions();
    }

    tabHost.addTab(tabSpec);
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:19,代码来源:MFBMain.java

示例5: initTabs

import android.widget.TabHost; //导入方法依赖的package包/类
private void initTabs() {
    MainTabs[] tabs = MainTabs.values();
    for (MainTabs tab : tabs) {
        TabHost.TabSpec tabSpec = mTabHost.newTabSpec(getString(tab.getNameRes()));

        View indicator = inflateView(R.layout.view_tab_main_indicator);
        ImageView icon = (ImageView) indicator.findViewById(R.id.tab_icon);
        icon.setImageResource(tab.getIconRes());
        TextView title = (TextView) indicator.findViewById(R.id.tab_titile);
        title.setText(getString(tab.getNameRes()));

        tabSpec.setIndicator(indicator);
        tabSpec.setContent(new TabHost.TabContentFactory() {
            @Override
            public View createTabContent(String tag) {
                return new View(MainActivity.this);
            }
        });

        mTabHost.addTab(tabSpec, tab.getClazz(), null);
    }
}
 
开发者ID:godblessyouandme,项目名称:appFirst,代码行数:23,代码来源:MainActivity.java

示例6: initView

import android.widget.TabHost; //导入方法依赖的package包/类
/**
     * 初始化组件
     */
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.layout_bottomnavigation);
        mTabHost = (MyFragmentTabHost) findViewById(R.id.tabhost);
        //实例化布局对象

        //实例化TabHost对象,得到TabHost
        mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
//        mTabHost.getTabWidget().setDividerDrawable(R.color.white);
//        mTabHost.getTabWidget().setStripEnabled(true);
        //得到fragment的个数
        int count = getFragmentArray().length;

        for (int i = 0; i < count; i++) {
            //为每一个Tab按钮设置图标、文字和内容
            TabHost.TabSpec tabSpec = mTabHost.newTabSpec(getTextviewArray()[i]).setIndicator(getTabItemView(i));
            //将Tab按钮添加进Tab选项卡中
            mTabHost.addTab(tabSpec, getFragmentArray()[i], null);
            //设置Tab按钮的背景
            mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.color.bottom_color);
        }
    }
 
开发者ID:dscn,项目名称:ktball,代码行数:25,代码来源:BaseBottomNoToolBarNavigationFrame.java

示例7: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
        tabSpec.setContent(new DummyTabFactory(mContext));
        String tag = tabSpec.getTag();

        TabInfo info = new TabInfo(tag, clss, args);

        if (mAttached) {
            // If we are already attached to the window, then check to make
            // sure this tab's fragment is inactive if it exists. This shouldn't
            // normally happen.
            info.fragment = mFragmentManager.findFragmentByTag(tag);
            if (info.fragment != null && !info.fragment.isDetached()) {
                FragmentTransaction ft = mFragmentManager.beginTransaction();
//				ft.detach(info.fragment);
                ft.hide(info.fragment);
                ft.commitAllowingStateLoss();
            }
        }

        mTabs.add(info);
        addTab(tabSpec);
    }
 
开发者ID:lizubing1992,项目名称:Li-MVPArms,代码行数:23,代码来源:FragmentTabHost.java

示例8: setupTab

import android.widget.TabHost; //导入方法依赖的package包/类
protected void setupTab(TabHost tabHost, String text, int viewId, int tabId)
{
	View tabview = LayoutInflater.from(tabHost.getContext()).inflate(tabId, null);
	TextView tv = (TextView) tabview.findViewById(R.id.tabText);
	tv.setText(text);

	TabHost.TabSpec tab = tabHost.newTabSpec(text);
	tab.setIndicator(tabview);
	tab.setContent(viewId);
	tabHost.addTab(tab);
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:12,代码来源:DocActivityView.java

示例9: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
	public View onCreateView(final LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = super.onCreateView(inflater, container, savedInstanceState);
		
		final TabHost tabHost = (TabHost) view.findViewById(android.R.id.tabhost);
    	
		tabHost.setup();
//        TabHost.TabSpec spec = tabHost.newTabSpec("Chat");
//        spec.setIndicator("Chat");
//        spec.setContent(new TabHost.TabContentFactory() {
//			@Override
//			public View createTabContent(String tag) {
//				return inflater.inflate(R.layout.game_chat, null);
//			}
//		});
//        tabHost.addTab(spec);

		TabHost.TabSpec spec = tabHost.newTabSpec("Games");
        spec.setIndicator("Games");
        spec.setContent(new TabHost.TabContentFactory() {

            @Override
            public View createTabContent(String tag) {
                return (new Button(getActivity()));
            }
        });
        tabHost.addTab(spec);
        
        return view;
	}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:32,代码来源:ContactDetailFragment.java

示例10: initView

import android.widget.TabHost; //导入方法依赖的package包/类
private void initView() {
    //测试栏目的题目统计TextView
    mCount = (TextView) findViewById(R.id.tv_count);
    mDoubleClickExit = new DoubleClickExitHelper(this);

    Indicator[] indicators = Indicator.values();
    mFragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mFragmentTabHost.setup(getApplicationContext(), getSupportFragmentManager(), R.id.realtabcontent);

    //初始化Tab
    for (int i = 0; i < indicators.length; i++){
        TabHost.TabSpec tabSpec = mFragmentTabHost.newTabSpec(getString(indicators[i].getResName()));
        tabSpec.setIndicator(getIndicatorView(indicators[i]));
        mFragmentTabHost.addTab(tabSpec, indicators[i].getClz(), null);
    }
    //去除底部按钮之间的分割线
    if (android.os.Build.VERSION.SDK_INT > 10) {
        mFragmentTabHost.getTabWidget().setShowDividers(0);

        mFragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
            @Override
            public void onTabChanged(String tabId) {
                if(tabId.equals(getString(Indicator.TEST.getResName()))){
                    mCount.setVisibility(View.VISIBLE);
                }else{
                    mCount.setVisibility(View.GONE);
                }
            }
        });
}}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:31,代码来源:MainActivity.java

示例11: setTabInfo

import android.widget.TabHost; //导入方法依赖的package包/类
private void setTabInfo() {
    int count = fragmentArray.length;

    mTabHost.setCurrentTab(0);
    mTabHost.clearAllTabs();
    for(int i=0;i<count; i++) {
        TabHost.TabSpec tabSpec= mTabHost.newTabSpec(mTextviewArray[i]).setIndicator(getTabItemView(i));
        mTabHost.addTab(tabSpec, fragmentArray[i], null);
    }
}
 
开发者ID:dearcode,项目名称:candy-android,代码行数:11,代码来源:MainActivity.java

示例12: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    rootView= inflater.inflate(R.layout.fragment_first_aid, container, false);



    viewPager = (ViewPager) rootView.findViewById(R.id.view_pager);
    List<Fragment> listFragments = new ArrayList<Fragment>();
    listFragments.add(new BurnsFragment());
    listFragments.add(new CprFragment());
    listFragments.add(new Fragment3());

    viewPager.setOffscreenPageLimit(listFragments.size());

    MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getFragmentManager(),listFragments);
    viewPager.setAdapter(myFragmentPagerAdapter);
    viewPager.setOnPageChangeListener(this);
    tabHost = (TabHost) rootView.findViewById(R.id.tabHost);
    tabHost.setup();

    String[] tabNames = {"Burns", "CPR", "Fire"};
    for(int i=0; i<tabNames.length; i++){
        TabHost.TabSpec tabSpec;
        tabSpec = tabHost.newTabSpec(tabNames[i]);
        tabSpec.setIndicator(tabNames[i]);
        tabSpec.setContent(new FakeContent(getActivity().getApplicationContext()));
        tabHost.addTab(tabSpec);
    }
    tabHost.setOnTabChangedListener(this);

    return rootView;
}
 
开发者ID:DamianPilot382,项目名称:Health-App,代码行数:34,代码来源:FirstAidFragment.java

示例13: getIndicator

import android.widget.TabHost; //导入方法依赖的package包/类
private TabHost.TabSpec getIndicator(Context context, TabHost.TabSpec spec,
                                     String color, String str, int genResIcon) {
    View v = LayoutInflater.from(context).inflate(R.layout.tab_item, null);
    TextView tabText = (TextView) v.findViewById(R.id.tab_text);
    ImageView tabImage = (ImageView) v.findViewById(R.id.tab_image);

    v.setBackgroundColor(Color.parseColor(color));
    tabText.setText(str);
    tabText.setTextColor(Color.WHITE);
    tabImage.setBackgroundResource(genResIcon);

    return spec.setIndicator(v);
}
 
开发者ID:zhouyizirui,项目名称:Leetroid,代码行数:14,代码来源:MainActivity.java

示例14: getNewTabSpec

import android.widget.TabHost; //导入方法依赖的package包/类
private TabHost.TabSpec getNewTabSpec(final View view, String title, int icon)
{
	final TabHost.TabSpec tabSpec = tabHost.newTabSpec(title);
	tabSpec.setContent(new TabHost.TabContentFactory()
	{
		public View createTabContent(String tag)
		{
			return view;
		}
	});
	tabSpec.setIndicator("", ContextCompat.getDrawable(activity, icon));
	return tabSpec;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:14,代码来源:TabHandler.java

示例15: setupTabs

import android.widget.TabHost; //导入方法依赖的package包/类
private void setupTabs() {
    mTabHost.setup();

    TabHost.TabSpec tabSpec;
    tabSpec = mTabHost.newTabSpec(getString(R.string.stock_detail_tab1));
    tabSpec.setIndicator(getString(R.string.stock_detail_tab1));
    tabSpec.setContent(android.R.id.tabcontent);
    mTabHost.addTab(tabSpec);

    tabSpec = mTabHost.newTabSpec(getString(R.string.stock_detail_tab2));
    tabSpec.setIndicator(getString(R.string.stock_detail_tab2));
    tabSpec.setContent(android.R.id.tabcontent);
    mTabHost.addTab(tabSpec);

    tabSpec = mTabHost.newTabSpec(getString(R.string.stock_detail_tab3));
    tabSpec.setIndicator(getString(R.string.stock_detail_tab3));
    tabSpec.setContent(android.R.id.tabcontent);
    mTabHost.addTab(tabSpec);

    mTabHost.setOnTabChangedListener(this);

    if (mSelectedTab.equals(getString(R.string.stock_detail_tab2))) {
        mTabHost.setCurrentTab(1);
    } else if (mSelectedTab.equals(getString(R.string.stock_detail_tab3))) {
        mTabHost.setCurrentTab(2);
    } else {
        mTabHost.setCurrentTab(0);
    }
}
 
开发者ID:DmitryMalkovich,项目名称:stock-hawk-app,代码行数:30,代码来源:StockDetailFragment.java


注:本文中的android.widget.TabHost.TabSpec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。