当前位置: 首页>>代码示例>>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;未经允许,请勿转载。