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


Java FragmentTabHost.setup方法代码示例

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


在下文中一共展示了FragmentTabHost.setup方法的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: 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

示例6: 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

示例7: 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

示例8: initView

import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
private void initView() {
    mAddItem = (LinearLayout) findViewById(R.id.main_add_item);
    mTabHost = (FragmentTabHost) findViewById(R.id.main_tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.main_container);
    mTabHost.setBackgroundColor(getResources().getColor(R.color.bg_tabhost));
    mTabHost.getTabWidget().setDividerDrawable(null);
    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (tabId.equals(BlackListFragmet.NAME)) {
                mActionBar.setTitle("黑名单", LocalActionBar.MIDDLE_TITLE);
        //        mAddItem.setVisibility(View.VISIBLE);
            } else {
                mActionBar.setTitle("添加", LocalActionBar.MIDDLE_TITLE);
        //        mAddItem.setVisibility(View.GONE);
            }
        }
    });
    addTabItem(BlackListFragmet.NAME, "黑名单", BlackListFragmet.TAB_ICON, BlackListFragmet.class);
    addTabItem(AddDataFragment.NAME, "添加", AddDataFragment.TAB_ICON, AddDataFragment.class);
}
 
开发者ID:facetome,项目名称:Interceptor,代码行数:22,代码来源:MainActivity.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: PagerTabHostBuilder

import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
/**
 * <pre>
 * Use
 *  android.R.id.tabhost    as tabhost id,
 *  android.R.id.tabcontent as invisible tabcontent id
 * </pre>
 * @see FragmentTabHost
 * @see ViewPager
 * @see android.R.id.tabhost
 * @see android.R.id.tabcontent
 */
public PagerTabHostBuilder(Context context, int pagerId, FragmentManager fragmentManager, ViewFinder viewFinder) {
  // assert context != null;
  // assert fragmentManager != null;
  // assert viewFinder != null;
  ViewPager       pager   = viewFinder.findView(pagerId, ViewPager.class);
  FragmentTabHost tabHost = viewFinder.findView(android.R.id.tabhost , FragmentTabHost.class);

  AssertUtils.checkNotEmpty(pager  , "pager not found"  );
  AssertUtils.checkNotEmpty(tabHost, "tabHost not found");

  tabHost.setup(context, fragmentManager, android.R.id.tabcontent);
  this.tabHost = tabHost;
  this.pager   = pager;
  this.fragmentManager = fragmentManager;
  this.context = context;
  this.tabTitleMap = new SparseArray<>();
}
 
开发者ID:lexjoy,项目名称:lex-utils,代码行数:29,代码来源:PagerTabHostBuilder.java

示例13: 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

示例14: onCreate

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

    mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple",this.getResources().getDrawable(R.drawable.i1)), Fragment1.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts1").setIndicator("Contacts1",this.getResources().getDrawable(R.drawable.i2)), Fragment2.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts2").setIndicator("Contacts1",this.getResources().getDrawable(R.drawable.i3)), Fragment3.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts3").setIndicator("Contacts1",this.getResources().getDrawable(R.drawable.i1)), Fragment4.class, null);
    mTabHost.setCurrentTab(2);

}
 
开发者ID:amar19860330,项目名称:amar-android-demo,代码行数:17,代码来源:TabHostDemoActivity.java

示例15: 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


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