本文整理匯總了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);
}