Java Code Examples for android.support.v4.app.FragmentTabHost

The following are top voted examples for showing how to use android.support.v4.app.FragmentTabHost. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Sparkplug   File: ConnectionFragment.java   View source code 7 votes vote down vote up
@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;
}
 
Example 2
Project: V2I-Traffic-Light-Demonstrator   File: MainActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 3
Project: shareNote   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onInit() {
    super.onInit();
    mProgressDialog = ProgressDialog.show(this, "请稍等", "获取数据中", true);
    Bmob.initialize(this, "3d9d9f910c51b02eea3d605178911aa5");
    if (BmobUser.getCurrentUser(User.class) == null) {
        startActivity(new Intent(MainActivity.this, LoginActivity.class));
    }

    tabHost = (FragmentTabHost) findViewById(R.id.tabHost);

    View view = navigationView.inflateHeaderView(R.layout.header_layout);
    username = (TextView) view.findViewById(R.id.usernameId);
    headImage = (ImageView) view.findViewById(R.id.headId);
    imgUserInfoBg = (ImageView) view.findViewById(R.id.imgBackground);
    presenter.requestUserInfo();

    initView();
    //初始化TabHost
    initTabHost();
    //初始化pager
    initPager();
    //添加监听关联TabHost和viewPager
    bindTabAndPager();
}
 
Example 4
Project: smart-farmer-android   File: NavBarActivity.java   View source code 6 votes vote down vote up
@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);

}
 
Example 5
Project: findlunch   File: RestaurantFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 6
Project: lemon-android   File: FragmentHelper.java   View source code 6 votes vote down vote up
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);
}
 
Example 7
Project: BitkyShop   File: MainActivity.java   View source code 6 votes vote down vote up
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);
}
 
Example 8
Project: FHWS-MobileApplikationen   File: MainActivity.java   View source code 6 votes vote down vote up
@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);

}
 
Example 9
Project: AndroidDemos   File: FragmentMain.java   View source code 6 votes vote down vote up
@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);
		}
	
}
 
Example 10
Project: Interceptor   File: MainActivity.java   View source code 6 votes vote down vote up
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);
}
 
Example 11
Project: TigreApp   File: FotosTabsFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 12
Project: TigreApp   File: RutaTabsFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 13
Project: BottomTabBar   File: MainActivity.java   View source code 6 votes vote down vote up
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);
	}
}
 
Example 14
Project: lex-utils   File: PagerTabHostBuilder.java   View source code 6 votes vote down vote up
/**
 * <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<>();
}
 
Example 15
Project: informant-droid   File: FragmentTabs.java   View source code 6 votes vote down vote up
@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);
}
 
Example 16
Project: informant-droid   File: FragmentTabsFragmentSupport.java   View source code 6 votes vote down vote up
@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;
}
 
Example 17
Project: informant-droid   File: FragmentNestingTabsSupport.java   View source code 6 votes vote down vote up
@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);
}
 
Example 18
Project: V.FlyoutTest   File: FragmentTabs.java   View source code 6 votes vote down vote up
@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);
}
 
Example 19
Project: V.FlyoutTest   File: FragmentTabsFragmentSupport.java   View source code 6 votes vote down vote up
@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;
}
 
Example 20
Project: V.FlyoutTest   File: FragmentNestingTabsSupport.java   View source code 6 votes vote down vote up
@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);
}
 
Example 21
Project: coolreader   File: DisplayNovelTabFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 22
Project: menadi   File: MapsContainerFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setHasOptionsMenu(true);
    getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    getActivity().getActionBar().setDisplayShowTitleEnabled(true);
    getActivity().getActionBar().setTitle((getResources().getStringArray(R.array.menu_array))[1]);

    Bundle arg = new Bundle();
    mapsTabs = getResources().getStringArray(R.array.maps_tabs);

    tabHost = new FragmentTabHost(getActivity());
    tabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);

    for(int i=0; i<mapsTabs.length; i++) {
        arg.putString("map" + i, mapsTabs[i]);
    }
    tabHost.addTab(tabHost.newTabSpec("tabMapTest1").setIndicator(mapsTabs[0]), GlobalMapFragment.class, arg);
    tabHost.addTab(tabHost.newTabSpec("tabMapTest2").setIndicator(mapsTabs[1]), LocalMapFragment.class, arg);
    return tabHost;
}
 
Example 23
Project: amar-android-demo   File: TabHostDemoActivity.java   View source code 6 votes vote down vote up
@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);

}
 
Example 24
Project: UltimateCom   File: ConnectionConfigActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_connection_config);

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

    tabHost.addTab(tabHost.newTabSpec("tty").setIndicator("TTY"),
            TtyConfigFragment.class, null);
    tabHost.addTab(tabHost.newTabSpec("usbserial").setIndicator("USB"),
            UsbSerialConfigFragment.class, null);
    tabHost.addTab(tabHost.newTabSpec("ioi").setIndicator("IOIO"),
            IoioConfigFragment.class, null);
    tabHost.addTab(tabHost.newTabSpec("bluetooth").setIndicator("BT"),
            BluetoothConfigFragment.class, null);
    tabHost.addTab(tabHost.newTabSpec("socket").setIndicator("TCP"),
            TcpConfigFragment.class, null);
}
 
Example 25
Project: android-holo-colors-sample   File: ListActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list);

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

	View tabIndicator1 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo, mTabHost.getTabWidget(), false);
	TextView title = (TextView) tabIndicator1.findViewById(android.R.id.title);
	title.setText("Tab n1");
	View tabIndicator2 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo, mTabHost.getTabWidget(), false);
	title = (TextView) tabIndicator2.findViewById(android.R.id.title);
	title.setText("Tab n2");
	View tabIndicator3 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo, mTabHost.getTabWidget(), false);
	title = (TextView) tabIndicator3.findViewById(android.R.id.title);
	title.setText("Tab n3	");

	mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator(tabIndicator1), ListFragment.class, null);
	mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator(tabIndicator2), ListFragment.class, null);
	mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator(tabIndicator3), ListFragment.class, null);

}
 
Example 26
Project: ArmaConnect   File: WeatherActivity.java   View source code 6 votes vote down vote up
@Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_weather);
     
     if (SettingsActivity.keepScreenOn())
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
     
     //https://stackoverflow.com/questions/5069614/tabwidget-overlaps-with-my-activity-content
     //https://stackoverflow.com/questions/22124124/tabs-are-on-top-of-my-text-in-my-xml
     //https://stackoverflow.com/questions/19831773/android-tabs-content-overlapping
     
     tabHost = (FragmentTabHost) findViewById(R.id.tabhost);
     tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);

     tabHost.addTab(tabHost.newTabSpec(getResources().getString(R.string.weather_Current)).setIndicator(getResources().getString(R.string.weather_Current), null), WeatherFragmentTab.class, null);
     tabHost.addTab(tabHost.newTabSpec(getResources().getString(R.string.weather_Forecast)).setIndicator(getResources().getString(R.string.weather_Forecast), null), WeatherFragmentTab.class, null);
     
     if (weatherThread == null) {
      weatherThread = new Thread(this);
weatherThread.start();
mutex = true;
     }
 }
 
Example 27
Project: godlibrary   File: ViewPagerTabHost.java   View source code 5 votes vote down vote up
private ViewPagerTabHost(FragmentTabHost fth, ViewPager vp, FragmentManager fm) {
    this.fragmentTabHost = fth;
    this.viewPager = vp;
    this.fragmentManager = fm;

    fragmentTabHost.setOnTabChangedListener(this);//选择 table事件
    viewPager.addOnPageChangeListener(this);//滑动Page事件
   // viewPager.setOffscreenPageLimit(1);
}
 
Example 28
Project: civify-app   File: ProfileFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_profile, container, false);

    if (!isUserSet()) return view;

    if (!isCurrentUser()) {
        DrawerActivity activity = (DrawerActivity) getActivity();
        Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
        if (toolbar != null) toolbar.setTitle(mUser.getFullName());
        activity.updateMenu();
    }

    FragmentTabHost tabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
    tabHost.setup(getContext(), getChildFragmentManager(), android.R.id.tabcontent);

    ProfileInfoFragment profileInfoFragment = ProfileInfoFragment.newInstance(mUser);
    IssuesProfileFragment issuesFragment = IssuesProfileFragment.newInstance(mUser);
    BadgeViewFragment badgeViewFragment = BadgeViewFragment.newInstance(mUser);

    tabHost.addTab(tabHost.newTabSpec(getString(R.string.tab_spec_issues))
                            .setIndicator(getString(R.string.tab_label_issues), null),
                        issuesFragment.getClass(), issuesFragment.getArguments());
    tabHost.addTab(tabHost.newTabSpec(getString(R.string.tab_spec_badges))
                    .setIndicator(getString(R.string.tab_label_badges), null),
                        badgeViewFragment.getClass(), badgeViewFragment.getArguments());

    getChildFragmentManager().beginTransaction()
            .replace(R.id.profile_info_fragment_placeholder, profileInfoFragment).commit();

    return view;
}
 
Example 29
Project: Yuneec-SDK-Android-Example   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    context = this;
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
    mTabHost.addTab(mTabHost.newTabSpec("connection")
                    .setIndicator("Home"), ConnectionFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("camera")
                    .setIndicator("Camera"), CameraFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("actions")
                    .setIndicator("Actions"), ActionFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("gimbal")
                    .setIndicator("Gimbal"), GimbalFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("media-download")
                    .setIndicator("Media Download"), MediaDownloadFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("telemetry")
                    .setIndicator("Telemetry"), TelemetryFragment.class, null);
    if (isSt16()) {
        mTabHost.addTab(mTabHost.newTabSpec("st16")
                        .setIndicator("St16"), St16Fragment.class, null);
    }

    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
        View v = mTabHost.getTabWidget().getChildAt(i);
        TextView tv = (TextView) v.findViewById(android.R.id.title);
        tv.setTextColor(ContextCompat.getColor(this, R.color.orangeDark));
        tv.setTextSize(16);
    }

}
 
Example 30
Project: Review-   File: MainActivity.java   View source code 5 votes vote down vote up
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);
                }
            }
        });
}}
 
Example 31
Project: RoadLab-Pro   File: MeasurementsFragment.java   View source code 5 votes vote down vote up
@Override
protected void initTabs(FragmentTabHost mTabHost) {
    Bundle measurementListBundle = new Bundle();
    measurementListBundle.putSerializable(MeasurementListFragment.ARG_MEASUREMENT_LIST, roadModel);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_list_tab_name))
        .setIndicator(getResources().getString(R.string.road_list_tab_name)), MeasurementListFragment.class, measurementListBundle);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_map_tab_name))
        .setIndicator(getResources().getString(R.string.road_map_tab_name)),MeasurementMapFragment.class, measurementListBundle);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_tags_tab_name))
        .setIndicator(getResources().getString(R.string.road_tags_tab_name)),
        TagsListFragment.class, measurementListBundle);
    mTabHost.setCurrentTab(0);
}
 
Example 32
Project: RoadLab-Pro   File: RoadFragment.java   View source code 5 votes vote down vote up
@Override
protected void initTabs(FragmentTabHost mTabHost) {
    Bundle roadListBundle = new Bundle();
    roadListBundle.putSerializable(RoadListFragment.ARG_ROAD_LIST, folder);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_list_tab_name))
            .setIndicator(getResources().getString(R.string.road_list_tab_name)), RoadListFragment.class, roadListBundle);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_map_tab_name))
            .setIndicator(getResources().getString(R.string.road_map_tab_name)),RoadMapFragment.class, roadListBundle);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_summary_tab_name))
            .setIndicator(getResources().getString(R.string.road_summary_tab_name)),RoadSummaryFragment.class, roadListBundle);
    mTabHost.setCurrentTab(0);
}
 
Example 33
Project: RoadLab-Pro   File: TagsFragment.java   View source code 5 votes vote down vote up
@Override
    protected void initTabs(FragmentTabHost mTabHost) {
//        Bundle measurementBundle = new Bundle();
//        measurementBundle.putSerializable(MeasurementDetailsListFragment.ARG_MEASUREMENT, measurementModel);
        mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.tags_list_tab_name))
           .setIndicator(getResources().getString(R.string.tags_list_tab_name)), TagsListFragment.class, null);
        mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.tags_map_tab_name))
           .setIndicator(getResources().getString(R.string.tags_map_tab_name)), TagsMapFragment.class, null);
        mTabHost.setCurrentTab(0);
    }
 
Example 34
Project: RoadLab-Pro   File: SummaryFragment.java   View source code 5 votes vote down vote up
@Override
protected void initTabs(FragmentTabHost mTabHost) {
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.measurements_tab_info_name))
            .setIndicator(getResources().getString(R.string.measurements_tab_info_name)), StartMeasurementFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.measurements_tab_map_name))
            .setIndicator(getResources().getString(R.string.measurements_tab_map_name)), StartMeasurementMapFragment.class, null);
    mTabHost.setCurrentTab(0);
}
 
Example 35
Project: RoadLab-Pro   File: MeasurementDetailsFragment.java   View source code 5 votes vote down vote up
@Override
protected void initTabs(FragmentTabHost mTabHost) {
    Bundle measurementBundle = new Bundle();
    measurementBundle.putSerializable(MeasurementDetailsListFragment.ARG_MEASUREMENT, measurementModel);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_list_tab_name))
       .setIndicator(getResources().getString(R.string.road_list_tab_name)), MeasurementDetailsListFragment.class, measurementBundle);
    mTabHost.addTab(mTabHost.newTabSpec(getResources().getString(R.string.road_map_tab_name))
       .setIndicator(getResources().getString(R.string.road_map_tab_name)), MeasurementDetailsMapFragment.class, measurementBundle);
    mTabHost.setCurrentTab(0);
}
 
Example 36
Project: FragmentTabHost   File: MainActivity.java   View source code 5 votes vote down vote up
private void initTabHost() {
    //实例化FragmentTabHost对象
    FragmentTabHost fragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    fragmentTabHost.setup(this,getSupportFragmentManager(),android.R.id.tabcontent);

    //去掉分割线
    fragmentTabHost.getTabWidget().setDividerDrawable(null);

    for (int i = 0; i<mTableItemList.size(); i++) {
        TabItem tabItem = mTableItemList.get(i);
        //实例化一个TabSpec,设置tab的名称和视图
        TabHost.TabSpec tabSpec = fragmentTabHost.newTabSpec(tabItem.getTitleString()).setIndicator(tabItem.getView());
        fragmentTabHost.addTab(tabSpec,tabItem.getFragmentClass(),null);

        //给Tab按钮设置背景
        fragmentTabHost.getTabWidget().getChildAt(i).setBackgroundColor(getResources().getColor(R.color.main_bottom_bg));

        //默认选中第一个tab
        if(i == 0) {
            tabItem.setChecked(true);
        }
    }

    fragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            //重置Tab样式
            for (int i = 0; i< mTableItemList.size(); i++) {
                TabItem tabitem = mTableItemList.get(i);
                if (tabId.equals(tabitem.getTitleString())) {
                    tabitem.setChecked(true);
                }else {
                    tabitem.setChecked(false);
                }
            }
        }
    });
}
 
Example 37
Project: honki_android2   File: FragmentTabHostFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_tab_host_fragment, container, false);

    // TabHostの初期化
    FragmentTabHost host = (FragmentTabHost) rootView.findViewById(R.id.tabHost);
    host.setup(getActivity(), getFragmentManager(), android.R.id.tabcontent);

    // ListViewFragmentのTabを追加
    TabHost.TabSpec tabSpec1 = host.newTabSpec("List").setIndicator("List");
    host.addTab(tabSpec1, ListViewFragment.class, null);

    // GridViewFragmentのTabを追加
    TabHost.TabSpec tabSpec2 = host.newTabSpec("Grid").setIndicator("Grid");
    host.addTab(tabSpec2, GridViewFragment.class, null);

    // ScrollViewFragmentのTabを追加
    TabHost.TabSpec tabSpec3 = host.newTabSpec("Scroll").setIndicator("Scroll");
    host.addTab(tabSpec3, ScrollViewFragment.class, null);

    // リスナーをセット
    host.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            //切り替えたTabのIDを表示
            Toast.makeText(getActivity(), "selected " + tabId, Toast.LENGTH_SHORT).show();
        }
    });

    return rootView;
}
 
Example 38
Project: KitchenSecret_Android   File: MainActivity.java   View source code 5 votes vote down vote up
private void initView() {
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mViewPager = (ViewPager) findViewById(R.id.view_pager);

    mFragmentList = new ArrayList<Fragment>();

    mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
    mTabHost.getTabWidget().setDividerDrawable(null);

    for (int i = 0;i < mClass.length;i++){
            TabHost.TabSpec tabSpec = mTabHost.newTabSpec(mTitles[i]).setIndicator(getTabView(i));
            mTabHost.addTab(tabSpec,mClass[i],null);
            mFragmentList.add(mFragment[i]);
            mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE);
    }

    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }
    });
}
 
Example 39
Project: flavordex   File: ViewEntryFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    final Context context = getContext();
    if(context == null) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    mTabHost = (FragmentTabHost)inflater.inflate(R.layout.tab_layout, container, false);
    mTabHost.setup(getContext(), getChildFragmentManager(), R.id.content);

    final Bundle tabArgs = new Bundle();
    tabArgs.putLong(ARG_ENTRY_ID, mEntryId);

    final Bundle args = getArguments();
    tabArgs.putLong(ARG_ENTRY_CAT_ID, args != null ? args.getLong(ARG_ENTRY_CAT_ID) : 0);

    Drawable icon;
    TabHost.TabSpec tab;

    icon = ActivityCompat.getDrawable(context, R.drawable.ic_description);
    tab = mTabHost.newTabSpec("info_" + mEntryId).setIndicator(null, icon);
    mTabHost.addTab(tab, getEntryInfoClass(), tabArgs);

    icon = ActivityCompat.getDrawable(context, R.drawable.ic_radar);
    tab = mTabHost.newTabSpec("flavors_" + mEntryId).setIndicator(null, icon);
    mTabHost.addTab(tab, ViewFlavorsFragment.class, tabArgs);

    icon = ActivityCompat.getDrawable(context, R.drawable.ic_photo);
    tab = mTabHost.newTabSpec("photos_" + mEntryId).setIndicator(null, icon);
    mTabHost.addTab(tab, ViewPhotosFragment.class, tabArgs);

    return mTabHost;
}
 
Example 40
Project: JACWfA   File: StarterActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// turn screen on and lock
	{
		this.getWindow()
				.addFlags(
						WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
								| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
								| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
								| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
								| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

		PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
		// may be replaced with `shell input keyevent 26`
		WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
				| PowerManager.ACQUIRE_CAUSES_WAKEUP, "turn screen on");
		wl.acquire();
	}
	init();

	setContentView(R.layout.starter_layout);

	tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
	tabWidget = (TabWidget) findViewById(android.R.id.tabs);
	tabHost.setup(this, getSupportFragmentManager(),
			android.R.id.tabcontent);

	{
	    test = tabHost.newTabSpec(TEST_TAG);
		test.setIndicator("Test");
		tabHost.addTab(test, TestFragment.class, null);
	}

	{
		results = tabHost.newTabSpec(RESULTS_TAG);
		results.setIndicator("Results");
		tabHost.addTab(results, ResultsFragment.class, null);
	}
}