當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentTabHost.addTab方法代碼示例

本文整理匯總了Java中android.support.v4.app.FragmentTabHost.addTab方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTabHost.addTab方法的具體用法?Java FragmentTabHost.addTab怎麽用?Java FragmentTabHost.addTab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.FragmentTabHost的用法示例。


在下文中一共展示了FragmentTabHost.addTab方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_connection, container, false);

    Bundle bundle = new Bundle();
    bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle());

    // Initialise the tab-host
    mTabHost = (FragmentTabHost) rootView.findViewById(android.R.id.tabhost);
    mTabHost.setup(getActivity(), getChildFragmentManager(), android.R.id.tabcontent);
    // Add a tab to the tabHost
    mTabHost.addTab(mTabHost.newTabSpec("Messages").setIndicator("Messages"), HistoryFragment.class, bundle);
    mTabHost.addTab(mTabHost.newTabSpec("I/O").setIndicator("I/O"), PublishFragment.class, bundle);
    //mTabHost.addTab(mTabHost.newTabSpec("Subscribe").setIndicator("Subscribe"), SubscriptionFragment.class, bundle);
    mTabHost.addTab(mTabHost.newTabSpec("Tutorial").setIndicator("Tutorial"), TutorialFragment.class, bundle);

    return rootView;
}
 
開發者ID:Cirrus-Link,項目名稱:Sparkplug,代碼行數:21,代碼來源:ConnectionFragment.java

示例2: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

    mTabHost.addTab(mTabHost.newTabSpec("StatusCarTab").setIndicator("Status Car"),
            StatusCarTab.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("StatusPedestrianTab").setIndicator("Status PED"),
            StatusPedestrianTab.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("PedestrianTab").setIndicator("PED"),
            PedestrianTab.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("PriorityTab").setIndicator("Prio"),
            PriorityTab.class, null);


    mTabHost.addTab(mTabHost.newTabSpec("SettingsTab").setIndicator("..."),
            SettingsTab.class, null);
}
 
開發者ID:shreaker,項目名稱:V2I-Traffic-Light-Demonstrator,代碼行數:23,代碼來源:MainActivity.java

示例3: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
    mTabHost.getTabWidget().setBackgroundColor(getResources().getColor(R.color.tab_bg));
    mTabHost.getTabWidget().setDividerDrawable(null);
    mTabHost.setOnTabChangedListener(this);

    TabInfo[] tabs = createTabInfo();
    if (tabs != null) {

        for (TabInfo tabInfo : tabs) {
            mTabHost.addTab(mTabHost.newTabSpec(tabInfo.tag).setIndicator(getTabItemView(tabInfo.bitmapResId, getString(tabInfo.titleSId))),
                    tabInfo.fragment, null);
        }
    }

    mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height = (int) getResources().getDimension(R.dimen.tab_height);

}
 
開發者ID:beanu,項目名稱:smart-farmer-android,代碼行數:24,代碼來源:NavBarActivity.java

示例4: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Notify the activity that the restaurant fragment gets active
    mListener.onRestaurantFragmentGetsActive();

    // Create a fragment tab host that holds the tabs
    mTabHost = new FragmentTabHost(getActivity());
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.flResultContent);

    // Create the tabs
    mTabHost.addTab(mTabHost.newTabSpec(TAB_NAME_LIST).setIndicator(getString(R.string.tabList)),
            RestaurantItemFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec(TAB_NAME_MAP).setIndicator(getString(R.string.tabMap)),
            RestaurantMapFragment.class, null);

    return mTabHost;
}
 
開發者ID:andju,項目名稱:findlunch,代碼行數:19,代碼來源:RestaurantFragment.java

示例5: init

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
public void init(FragmentTabHost fragmentTabHost, Activity activity) {
	this.activity = activity;
       // 得到fragment的個數
       int count = classArray.length;

       for (int i = 0; i < count; i++) {
           // 給每個Tab按鈕設置圖標、文字和內容
           TabSpec tabSpec = fragmentTabHost.newTabSpec(labelArray[i]).setIndicator(
                   getTabItemView(i, activity));
           // 將Tab按鈕添加進Tab選項卡中
           fragmentTabHost.addTab(tabSpec, classArray[i], null);

           // 設置Tab按鈕的背景
           //mTabHost.getTabWidget().getChildAt(i)
           // .setBackgroundResource(R.drawable.tt_tab_bk);
       }
	this.selectTab(0);
	fragmentTabHost.setOnTabChangedListener(this);
}
 
開發者ID:xuhuisheng,項目名稱:lemon-android,代碼行數:20,代碼來源:FragmentHelper.java

示例6: initTab

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
private void initTab() {
  HomeFragment.setMainActivity(this);
  KyTab tab_home = new KyTab(HomeFragment.class, "主頁", R.drawable.navigationbar_selector_home);
  KyTab tab_hot = new KyTab(HotFragment.class, "便民", R.drawable.navigationbar_selector_hot);
  KyTab tab_category = new KyTab(CategrayFragment.class, "超市", R.drawable.navigationbar_selector_category);
  KyTab tab_cart = new KyTab(CartFragment.class, "購物車", R.drawable.navigationbar_selector_cart);
  KyTab tab_user = new KyTab(UserFragment.class, "個人", R.drawable.navigationbar_selector_user);
  kyTabs.add(tab_home);
  kyTabs.add(tab_hot);
  kyTabs.add(tab_category);
  kyTabs.add(tab_cart);
  kyTabs.add(tab_user);

  fragmentTabHost = (FragmentTabHost) findViewById(R.id.fragmentTabHost);
  fragmentTabHost.setup(mContext, getSupportFragmentManager(), R.id.fragment);

  for (KyTab tab : kyTabs) {
    TabHost.TabSpec tabSpec =
        fragmentTabHost.newTabSpec(tab.getTitle()).setIndicator(buildIndicator(tab));
    fragmentTabHost.addTab(tabSpec, tab.getFragment(), null);
  }

  fragmentTabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
  fragmentTabHost.setCurrentTab(0);
}
 
開發者ID:bitkylin,項目名稱:BitkyShop,代碼行數:26,代碼來源:MainActivity.java

示例7: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	setContentView(R.layout.fragment_tabs);
       mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
       mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

       mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
               Tab1.class, null);
       mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
               Tab2.class, null);
       mTabHost.addTab(mTabHost.newTabSpec("duda").setIndicator("Duda Test"),
               Tab2.class, null);

}
 
開發者ID:DerGary,項目名稱:FHWS-MobileApplikationen,代碼行數:18,代碼來源:MainActivity.java

示例8: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	 setContentView(R.layout.fragment_main);
	

	tabHost =(FragmentTabHost) findViewById(R.id.fth_main);
	tabHost.setup(getApplication(), getSupportFragmentManager(), R.id.fl_main);
	
	for (int i = 0; i < 5; i++) {
		TabSpec tab = tabHost.newTabSpec(i+"");
		
		View view = LayoutInflater.from(this).inflate(R.layout.menu, null);

	  	ImageView ivType = (ImageView) view.findViewById(R.id.iv_iconType);
	  	TextView tvName = (TextView) view.findViewById(R.id.tv_name);
	  	ivType.setImageResource(ResUtils.menuIds[i]);
	  	tvName.setText(ResUtils.menuStrs[i]);
		tab.setIndicator(view);
		
		Bundle b = new Bundle();
		b.putInt("position", i);
		tabHost.addTab(tab, MenuFragment.class, b);
		}
	
}
 
開發者ID:BarryLiu,項目名稱:AndroidDemos,代碼行數:27,代碼來源:FragmentMain.java

示例9: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    View rootView = inflater.inflate(R.layout.rutas_tabs, container, false);

    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Mis fotos");

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

    mTabHost.addTab(mTabHost.newTabSpec("lista").setIndicator("Lista"),
            FotosListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("mapa").setIndicator("Mapa"),
            FotosMapFragment.class, null);

    return rootView;
}
 
開發者ID:mrebordinos,項目名稱:TigreApp,代碼行數:19,代碼來源:FotosTabsFragment.java

示例10: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    View rootView = inflater.inflate(R.layout.rutas_tabs, container, false);

    String title = getArguments().getString("title");
    int rutaId = getArguments().getInt("idruta");

    Bundle bundle = new Bundle();
    bundle.putString("title", title);
    bundle.putInt("idruta", rutaId);

    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(title);

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

    mTabHost.addTab(mTabHost.newTabSpec("mapa").setIndicator("Mapa"),
            RutaViewFragment.class, bundle);
    mTabHost.addTab(mTabHost.newTabSpec("detalle").setIndicator("Detalle"),
            RutaDetalleFragment.class, bundle);

    return rootView;
}
 
開發者ID:mrebordinos,項目名稱:TigreApp,代碼行數:26,代碼來源:RutaTabsFragment.java

示例11: initView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
private void initView() {
	mLayoutInflater = LayoutInflater.from(this);

	mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
	mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

	int count = mFragmentArray.length;
	for (int i = 0; i < count; i++) {
		TabSpec spec = mTabHost.newTabSpec(getString(mTextArray[i]));
		spec.setIndicator(getTabItemView(i));

		mTabHost.addTab(spec, mFragmentArray[i], null);

		// mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_item_backgound_selector);
		mTabHost.getTabWidget().setDividerDrawable(null);
	}
}
 
開發者ID:alwaystrong,項目名稱:BottomTabBar,代碼行數:18,代碼來源:MainActivity.java

示例12: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_tabs);
    mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

    mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
            FragmentStackSupport.CountingFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            LoaderCursorSupport.CursorLoaderListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
            LoaderCustomSupport.AppListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
            LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
}
 
開發者ID:reknih,項目名稱:informant-droid,代碼行數:18,代碼來源:FragmentTabs.java

示例13: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mTabHost = new FragmentTabHost(getActivity());
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.fragment1);

    mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
            FragmentStackSupport.CountingFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            LoaderCursorSupport.CursorLoaderListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
            LoaderCustomSupport.AppListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
            LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);

    return mTabHost;
}
 
開發者ID:reknih,項目名稱:informant-droid,代碼行數:18,代碼來源:FragmentTabsFragmentSupport.java

示例14: onCreate

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mTabHost = new FragmentTabHost(this);
    setContentView(mTabHost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.fragment1);

    mTabHost.addTab(mTabHost.newTabSpec("menus").setIndicator("Menus"),
            FragmentMenuFragmentSupport.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            LoaderCursorSupport.CursorLoaderListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("stack").setIndicator("Stack"),
            FragmentStackFragmentSupport.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("tabs").setIndicator("Tabs"),
            FragmentTabsFragmentSupport.class, null);
}
 
開發者ID:reknih,項目名稱:informant-droid,代碼行數:18,代碼來源:FragmentNestingTabsSupport.java

示例15: onCreateView

import android.support.v4.app.FragmentTabHost; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	
   	View view = inflater.inflate(R.layout.fragment_display_novel_tab, container, false);
   	
       mTabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
       mTabHost.setup(getSherlockActivity(), getChildFragmentManager(), R.id.content);

       mTabHost.addTab(mTabHost.newTabSpec(MAIN_SPEC).setIndicator(MAIN_SPEC),
               DisplayLightNovelListFragment.class, null);
       mTabHost.addTab(mTabHost.newTabSpec(TEASER_SPEC).setIndicator(TEASER_SPEC),
               DisplayTeaserListFragment.class, null);
       mTabHost.addTab(mTabHost.newTabSpec(ORIGINAL_SPEC).setIndicator(ORIGINAL_SPEC),
               DisplayOriginalListFragment.class, null);

       return view;
}
 
開發者ID:dotcool,項目名稱:coolreader,代碼行數:18,代碼來源:DisplayNovelTabFragment.java


注:本文中的android.support.v4.app.FragmentTabHost.addTab方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。