當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentTabHost.setCurrentTab方法代碼示例

本文整理匯總了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);
}
 
開發者ID:bitkylin,項目名稱:BitkyShop,代碼行數:26,代碼來源:MainActivity.java

示例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);

}
 
開發者ID:amar19860330,項目名稱:amar-android-demo,代碼行數:17,代碼來源:TabHostDemoActivity.java

示例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);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:14,代碼來源:MeasurementsFragment.java

示例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);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:13,代碼來源:RoadFragment.java

示例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);
    }
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:11,代碼來源:TagsFragment.java

示例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);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:9,代碼來源:SummaryFragment.java

示例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);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:11,代碼來源:MeasurementDetailsFragment.java

示例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);

}
 
開發者ID:godblessyouandme,項目名稱:appFirst,代碼行數:16,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:leerduo,項目名稱:OschinaMainFrameWorkWithToolBar,代碼行數:28,代碼來源:MainActivity.java

示例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());
}
 
開發者ID:edx,項目名稱:edx-app-android,代碼行數:14,代碼來源:BaseTabActivity.java

示例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);
}
 
開發者ID:blueelwang,項目名稱:oschina-app,代碼行數:38,代碼來源:MainActivity.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:Silverpop,項目名稱:mobile-connector-sdk-android,代碼行數:41,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:447491480,項目名稱:ima_intellj,代碼行數:30,代碼來源:MainActivity.java

示例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);
    }
 
開發者ID:blueshen,項目名稱:androidTools,代碼行數:30,代碼來源:MainActivity.java

示例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);

}
 
開發者ID:dkzeb,項目名稱:studdyDokky,代碼行數:47,代碼來源:MainViewFragment.java


注:本文中的android.support.v4.app.FragmentTabHost.setCurrentTab方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。