本文整理汇总了Java中android.support.v4.app.FragmentTabHost.setCurrentTab方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTabHost.setCurrentTab方法的具体用法?Java FragmentTabHost.setCurrentTab怎么用?Java FragmentTabHost.setCurrentTab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentTabHost
的用法示例。
在下文中一共展示了FragmentTabHost.setCurrentTab方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: initTabs
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@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);
}
示例4: initTabs
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@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);
}
示例5: initTabs
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@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);
}
示例6: initTabs
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@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);
}
示例7: initTabs
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@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);
}
示例8: init
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
mPagerWrapper = (LinearLayout) findViewById(R.id.pager_wrapper);
mTagHeight = 0;
mPagerWrapper.setPadding(0, getActionBarSize() + mTagHeight, 0, 0);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.getTabWidget().setShowDividers(0);
initTabs();
mTabHost.setCurrentTab(0);
mTabHost.setOnTabChangedListener(this);
}
示例9: init
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
mToolbarView = findViewById(R.id.actionBar);
final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
findViewById(R.id.pager_wrapper).setPadding(0, getActionBarSize() + tabHeight, 0, 0);
mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
if (Build.VERSION.SDK_INT > 10) {
mTabHost.getTabWidget().setShowDividers(0);
}
initTabs();
mTabHost.setCurrentTab(0);
mTabHost.setOnTabChangedListener(this);
ViewConfiguration vc = ViewConfiguration.get(this);
mSlop = vc.getScaledTouchSlop();
mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
}
示例10: onPostCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
if (tabHost == null) {
throw new NoTabLayoutElementsException("Unable to find tabhost in layout");
}
if (findViewById(android.R.id.tabcontent) == null) {
throw new NoTabLayoutElementsException("Unable to find tabcontent in layout");
}
setUpTabs();
tabHost.setCurrentTab(getDefaultTab());
}
示例11: init
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
checkUpdate();
AppContext.instance().initLoginInfo();
mToolbarView = findViewById(R.id.actionBar);
final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
findViewById(R.id.pager_wrapper).setPadding(0, getActionBarSize() + tabHeight, 0, 0);
mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
if (Build.VERSION.SDK_INT > 10) {
mTabHost.getTabWidget().setShowDividers(0);
}
initTabs();
mTabHost.setCurrentTab(0);
mTabHost.setOnTabChangedListener(this);
IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_NOTICE);
registerReceiver(mNoticeReceiver, filter);
NoticeUtils.bindToService(this);
UIHelper.sendBroadcastForNotice(this);
ViewConfiguration vc = ViewConfiguration.get(this);
mSlop = vc.getScaledTouchSlop();
mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
}
示例12: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTabHost = (FragmentTabHost)findViewById(R.id.mainTabHost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.mainTabHost);
mTabHost.addTab(mTabHost.newTabSpec("Mobile Identity").setIndicator("Mobile Identity"),
MobileIdentityFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("XML API").setIndicator("XML API"),
XMLAPIFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("UBF Client").setIndicator("UBF Client"),
UBFAPIFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("Engage Config").setIndicator("Engage Config"),
EngageConfigFragment.class, null);
Intent intent = getIntent();
if (intent != null) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
String tabId = bundle.getString("tabId");
Log.d(TAG, "TabID : " + tabId);
if (tabId != null) {
if (tabId.equalsIgnoreCase("identity")) {
mTabHost.setCurrentTab(0);
} else if (tabId.equalsIgnoreCase("xml")) {
mTabHost.setCurrentTab(1);
} else if (tabId.equalsIgnoreCase("ubf")) {
mTabHost.setCurrentTab(2);
} else if (tabId.equalsIgnoreCase("config")) {
mTabHost.setCurrentTab(3);
}
}
}
}
}
示例13: init
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
// Intent intent = getIntent();
// if (intent != null) {
// mVersion = intent.getParcelableExtra(Version.BUNDLE_KEY_VERSION);
// }
AppContext.instance().initLoginInfo();
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
if (android.os.Build.VERSION.SDK_INT > 10) {
mTabHost.getTabWidget().setShowDividers(0);
}
initTabs();
mTabHost.setCurrentTab(0);
mTabHost.setOnTabChangedListener(this);
IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_NOTICE);
registerReceiver(mNoticeReceiver, filter);
NoticeUtils.bindToService(this);
UIHelper.sendBroadcastForNotice(this);
}
示例14: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Resources res = getResources(); // Resource object to get Drawables
FragmentTabHost tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, BatteryActivity.class);
spec = tabHost.newTabSpec("batteryTab").setIndicator("Battery")
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, MemoryActivity.class);
spec = tabHost.newTabSpec("memoryTab").setIndicator("Memory")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, PhoneActivity.class);
spec = tabHost.newTabSpec("phoneTab").setIndicator("Phone")
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
示例15: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_view_fragment);
// logo
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setTitle("studieDOKK1");
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.studiedokk1_logo_transparent_white);
}
mTabHost = (FragmentTabHost) findViewById(R.id.tabhost);
mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
public void onTabChanged(String tabId) {
View currentView = mTabHost.getCurrentView();
if (mTabHost.getCurrentTab() > currentTab) {
currentView.setAnimation(inFromRightAnimation());
} else {
currentView.setAnimation(outToRightAnimation());
}
currentTab = mTabHost.getCurrentTab();
}
});
mTabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("tab1").setIndicator("Aktiviteter", null),
ActivitiesGridFragment.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab2").setIndicator("Kort", null),
MapFragment.class, null);
TabWidget tw = mTabHost.getTabWidget();
System.out.println("TW cnt: "+tw.getTabCount());
for(int i = 0; i < tw.getTabCount(); i++){
TextView tv = (TextView) tw.getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(Color.WHITE);
}
mTabHost.setCurrentTab(1);
}