當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。