Java Code Examples for android.support.v4.app.FragmentTabHost#setCurrentTab()
The following examples show how to use
android.support.v4.app.FragmentTabHost#setCurrentTab() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From BitkyShop with MIT License | 6 votes |
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 2
Source File: RecordingActivity.java From voice-pitch-analyzer with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_recording); tabHost = (FragmentTabHost)findViewById(R.id.tabhost); tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); this.addTab(ReadingFragment.class, getString(R.string.title_text)); this.addTab(RecordGraphFragment.class, getString(R.string.realtime_graph)); SharedPreferences sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); Integer tabIndex = sharedPref.getInt(getString(R.string.recording_tab_index), 0); tabHost.setCurrentTab(tabIndex); }