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


Java TabLayout類代碼示例

本文整理匯總了Java中android.support.design.widget.TabLayout的典型用法代碼示例。如果您正苦於以下問題:Java TabLayout類的具體用法?Java TabLayout怎麽用?Java TabLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TabLayout類屬於android.support.design.widget包,在下文中一共展示了TabLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onActivityCreated

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState){
    super.onActivityCreated(savedInstanceState);

    mTabLayout=(TabLayout)view.findViewById(R.id.tabs);

    disease_num_chart_fragment Numchart=new disease_num_chart_fragment();
    disease_kind_chart_fragment Kindchart=new disease_kind_chart_fragment();
    disease_chart_fragment chart=new disease_chart_fragment();
    fragmentList.add(Numchart);
    fragmentList.add(Kindchart);
    fragmentList.add(chart);

    //去除陰影
    toolbar=(Toolbar)LayoutInflater.from(getActivity()).inflate(R.layout.activity_main,null).findViewById(R.id.toolBar);
    toolbar.setElevation(0);

    mViewPager=(ViewPager)view.findViewById(R.id.viewPager);
    adapter=new AnalysisAdapter(getChildFragmentManager(),fragmentList);
    mViewPager.setAdapter(adapter);

    mTabLayout.setupWithViewPager(mViewPager);

}
 
開發者ID:lupwei,項目名稱:Croprotector,代碼行數:25,代碼來源:Analysis_fragment.java

示例2: onCreate

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Schedule");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.getTabAt(1).select();
}
 
開發者ID:adithya321,項目名稱:Instincts-2k17,代碼行數:20,代碼來源:ScheduleActivity.java

示例3: onCreate

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.introduction_view_pager);

    ArrayList<IntroductionFragment> fragments = new ArrayList<>();
    initFragmentList(fragments);

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id
            .introduction_linear_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.introduction_view_pager);

    mPagerAdapter = new IntroductionPagerAdapter(getSupportFragmentManager(), fragments);
    viewPager.setAdapter(mPagerAdapter);

    TabLayout tabLayout = (TabLayout) linearLayout.findViewById(
            R.id.introduction_tab_layout);
    tabLayout.setupWithViewPager(viewPager, true);
}
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:20,代碼來源:IntroductionActivity.java

示例4: setTabUnSelectedState

import android.support.design.widget.TabLayout; //導入依賴的package包/類
private void setTabUnSelectedState(TabLayout.Tab tab) {
    View customView = tab.getCustomView();
    TextView tabText = (TextView) customView.findViewById(R.id.tv_tab_text);
    ImageView tabIcon = (ImageView) customView.findViewById(R.id.iv_tab_icon);
    tabText.setTextColor(ContextCompat.getColor(this, R.color.black_1));
    String s = tabText.getText().toString();
    if (getString(R.string.item_home).equals(s)) {
        tabIcon.setImageResource(R.drawable.home);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    }
}
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:17,代碼來源:MainActivity.java

示例5: setupPager

import android.support.design.widget.TabLayout; //導入依賴的package包/類
public void setupPager() {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    //adapter.addFragment(new LocalFileFragment(), getString(R.string.local_file_title));
    adapter.addFragment(new UserBookFragment(), getString(R.string.my_books));
    adapter.addFragment(new LibraryFragment(), getString(R.string.library));
    adapter.addFragment(new RecommendedFragmnet(), getString(R.string.recommended));
    adapter.addFragment(new UploadFragment(), getString(R.string.upload));
    mViewPager.setAdapter(adapter);
    mTabLayout.setupWithViewPager(mViewPager);

    if (utils.getWidthDeviceDP() > 400) {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    } else {
        mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
 
開發者ID:OlegKlimenko,項目名稱:Plamber-Android,代碼行數:17,代碼來源:LibraryActivity.java

示例6: onCreate

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_theme_font);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setupToolbar();

    FirebaseAnalytics.getInstance(this).logEvent("open_choose_font_theme", new Bundle());

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    adapter = new SectionPageAdapter(getSupportFragmentManager(), this);
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(3);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(viewPager);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:17,代碼來源:ThemeFontActivity.java

示例7: onCreate

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Fabric.with(this, new Crashlytics());

    Log.i(TAG, "Creating main activity");

    setContentView(R.layout.activity_main);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    TabsAdapter tabsAdapter = new TabsAdapter(getSupportFragmentManager(), MainActivity.this);
    viewPager.setAdapter(tabsAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
 
開發者ID:jansipke,項目名稱:pvdisplay,代碼行數:21,代碼來源:MainActivity.java

示例8: initViews

import android.support.design.widget.TabLayout; //導入依賴的package包/類
private void initViews(View view) {

        tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
        ViewPager viewPager = (ViewPager) view.findViewById(R.id.view_pager);
        viewPager.setOffscreenPageLimit(3);

        adapter = new MainPagerAdapter(
                getChildFragmentManager(),
                context,
                zhihuDailyFragment,
                guokrFragment,
                doubanMomentFragment);

        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:MainFragment.java

示例9: run

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
public void run()
{

    if(tabLayout6.getWidth() < TutorialsActivity.this.getResources().getDisplayMetrics().widthPixels)
    {
        tabLayout6.setTabMode(TabLayout.MODE_FIXED);
        ViewGroup.LayoutParams mParams = tabLayout6.getLayoutParams();
        mParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
        tabLayout6.setLayoutParams(mParams);

    }
    else
    {
        tabLayout6.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:18,代碼來源:TutorialsActivity.java

示例10: initActivityCreated

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void initActivityCreated() {
    switch (type) {
        case ApiConfig.Type.DYTT:
            tabLayout.setTabMode(TabLayout.MODE_FIXED);
            break;
        case ApiConfig.Type.DY_2018:
        case ApiConfig.Type.XIAO_PIAN:
        case ApiConfig.Type.PIAO_HUA:
        case ApiConfig.Type.K_567:
            tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
            break;
    }
    TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager(), type);
    viewPager.setAdapter(tabAdapter);
    tabLayout.setupWithViewPager(viewPager);
    viewPager.setOffscreenPageLimit(tabAdapter.getCount());
}
 
開發者ID:7449,項目名稱:JsoupSample,代碼行數:19,代碼來源:TabFragment.java

示例11: init

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
public void init() {
    super.init();
    activityFragment = new ActivityFragment();
    articleFragment = new ArticleFragment();

    fragments.add(articleFragment);
    fragments.add(activityFragment);
    titles.add(ARTICLE);
    titles.add(ACTIVITY);

    pageAdapter = new PageAdapter(getChildFragmentManager(), fragments, titles);

    viewPager.setAdapter(pageAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);

    bgaBanner.setData(R.drawable.banner1, R.drawable.banner2, R.drawable.banner3, R.drawable.banner4);
    bgaBanner.setDelegate(new BGABanner.Delegate() {
        @Override
        public void onBannerItemClick(BGABanner banner, View itemView, Object model, int position) {
            showToast(position + "");
        }
    });
}
 
開發者ID:HowieTianDev,項目名稱:ChenYan,代碼行數:26,代碼來源:HomeFragment.java

示例12: configFragments

import android.support.design.widget.TabLayout; //導入依賴的package包/類
private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new FirstFragment());
    list.add(new MiddleFragment());
    list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
    List<String> listTitle = new ArrayList<>();
    listTitle.add("係統組件");
    listTitle.add("自定義View");
    listTitle.add("第三方庫控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
 
開發者ID:wutongke,項目名稱:AndroidSkinAnimator,代碼行數:17,代碼來源:MainActivity.java

示例13: initialize

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
    protected void initialize() {
        types.add("Android");
        types.add("IOS");
        types.add("前端");
        types.add("拓展資源");
//        types.add("瞎推薦");
//        types.add("福利");
        fragments.add(GankFragment.newInstance("Android"));
        fragments.add(GankFragment.newInstance("iOS"));
        fragments.add(GankFragment.newInstance("前端"));
        fragments.add(GankFragment.newInstance("拓展資源"));
//        fragments.add(GankFragment.newInstance("瞎推薦"));
//        fragments.add(GankFragment.newInstance("福利"));
        titleAdapter = new TitleAdapter(getChildFragmentManager(), fragments, types);
        viewPager.setAdapter(titleAdapter);
        tablayout.setTabMode(TabLayout.MODE_FIXED);
        tablayout.setupWithViewPager(viewPager);
    }
 
開發者ID:xiarunhao123,項目名稱:Ency,代碼行數:20,代碼來源:GankMainFragment.java

示例14: onCreate

import android.support.design.widget.TabLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    initTabList();
    mAdapter = new TabLayoutFragmentAdapter(getSupportFragmentManager(), mTabList, this, mFragments, mTabImgs);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
    mTabLayout.setupWithViewPager(mViewPager);
    mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    for (int i = 0; i < mTabLayout.getTabCount(); i++) {
        mTabLayout.getTabAt(i).setCustomView(mAdapter.getTabView(i));
    }
    mTabLayout.addOnTabSelectedListener(this);
}
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:21,代碼來源:MainActivity.java

示例15: initView

import android.support.design.widget.TabLayout; //導入依賴的package包/類
protected void initView() {
    findViewById(R.id.iv_github).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openMyGitHub();
        }


    });
    mPagerBehavior = (UcNewsHeaderPagerBehavior) ((CoordinatorLayout.LayoutParams) findViewById(R.id.id_uc_news_header_pager).getLayoutParams()).getBehavior();
    mPagerBehavior.setPagerStateListener(this);
    mNewsPager = (ViewPager) findViewById(R.id.id_uc_news_content);
    mTableLayout = (TabLayout) findViewById(R.id.id_uc_news_tab);
    mFragments = new ArrayList<TestFragment>();
    for (int i = 0; i < 4; i++) {
        mFragments.add(TestFragment.newInstance(String.valueOf(i), false));
        mTableLayout.addTab(mTableLayout.newTab().setText("Tab" + i));
    }
    mTableLayout.setTabMode(TabLayout.MODE_FIXED);
    mTableLayout.setOnTabSelectedListener(this);
    mNewsPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTableLayout));
    mNewsPager.setAdapter(new TestFragmentAdapter(mFragments, getSupportFragmentManager()));
}
 
開發者ID:Learzhu,項目名稱:UcMainPagerDemo-master,代碼行數:24,代碼來源:MainActivity.java


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