当前位置: 首页>>代码示例>>Java>>正文


Java TabLayout.setupWithViewPager方法代码示例

本文整理汇总了Java中android.support.design.widget.TabLayout.setupWithViewPager方法的典型用法代码示例。如果您正苦于以下问题:Java TabLayout.setupWithViewPager方法的具体用法?Java TabLayout.setupWithViewPager怎么用?Java TabLayout.setupWithViewPager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.TabLayout的用法示例。


在下文中一共展示了TabLayout.setupWithViewPager方法的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_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mLogoutPresenter = new LogoutPresenter(this);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    setupTabIcons();
}
 
开发者ID:mustafaozhan,项目名称:Howl,代码行数:17,代码来源:MainActivity.java

示例3: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chuck_activity_transaction);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    title = (TextView) findViewById(R.id.toolbar_title);

    final ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }

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

    transactionId = getIntent().getLongExtra(ARG_TRANSACTION_ID, 0);
    getSupportLoaderManager().initLoader(0, null, this);
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:24,代码来源:TransactionActivity.java

示例4: setupViewPager

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
public void setupViewPager(ViewPager viewPager,TabLayout tabLayout)
{
    //Instancia o TabAdapter, responsável pelo controle das tabs
    TabAdapter tabAdapter = new TabAdapter(getFragmentManager(),getActivity());
    for(int i=0;i<mFaltas.size();i++)
    {
        tabAdapter.addFrag(FaltasLista.newInstance(mFaltas.get(i),(i+1)),meses[i]);
    }
    //Define o Adapter e Mostra as Faltas
    viewPager.setAdapter(tabAdapter);
    viewPager.setOffscreenPageLimit(mFaltas.size());
    tabLayout.setupWithViewPager(viewPager);
    viewPager.setCurrentItem(mPosition);
}
 
开发者ID:alessandrojean,项目名称:order-by-android,代码行数:15,代码来源:FaltasFragment.java

示例5: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set the content of the activity to use the activity_main.xml layout file
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Find the view pager that will allow the user to swipe between fragments
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);

    // Create an adapter that knows which fragment should be shown on each page
    PlaceFragmentPagerAdapter adapter = new PlaceFragmentPagerAdapter(this, getSupportFragmentManager());

    // Set the adapter onto the view pager
    viewPager.setAdapter(adapter);

    // Find the tab layout that shows the tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);

    // Connect the tab layout with the view pager. This will
    //   1. Update the tab layout when the view pager is swiped
    //   2. Update the view pager when a tab is selected
    //   3. Set the tab layout's tab names with the view pager's adapter's titles
    //      by calling onPageTitle()
    tabLayout.setupWithViewPager(viewPager);
}
 
开发者ID:PascalR2014,项目名称:Tourguideapp,代码行数:30,代码来源:MainActivity.java

示例6: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.niclas_hoved_akt);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  ActionBar actionBar = getSupportActionBar();
  //actionBar.setHomeAsUpIndicator(R.drawable.ic_action_venstremenu);
  actionBar.setHomeAsUpIndicator(R.drawable.appikon);
  actionBar.setDisplayHomeAsUpEnabled(true);

  mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

  NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
  if (navigationView != null) {
    setupDrawerContent(navigationView);
  }

  ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
  if (viewPager != null) {
    setupViewPager(viewPager);
  }

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

  mCastContext = CastContext.getSharedInstance(this);

  mCastStateListener = new CastStateListener() {
    @Override
    public void onCastStateChanged(int newState) {
      if (newState != CastState.NO_DEVICES_AVAILABLE) {
        showIntroductoryOverlay();
      }
    }
  };
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:40,代码来源:NiclasHovedAkt.java

示例7: onViewCreated

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    TabLayout tabs = (TabLayout) view.findViewById(R.id.tab_movie_detail);
    ViewPager viewPager = (ViewPager) view.findViewById(R.id.vp_movie_detail);

    setUpBackdrop(view);
    setUpViewPager(viewPager);
    tabs.setupWithViewPager(viewPager);
}
 
开发者ID:ramadani,项目名称:Pilem,代码行数:12,代码来源:MovieDetailFragment.java

示例8: initViewPager

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void initViewPager() {
    mTabLayout = (TabLayout) findViewById(R.id.tabs);
    List<String> titles = new ArrayList<>();
    titles.add("精选");
    titles.add("体育");
    titles.add("巴萨");
    titles.add("购物");
    titles.add("明星");
    titles.add("视频");
    titles.add("健康");
    titles.add("励志");
    titles.add("图文");
    titles.add("本地");
    titles.add("动漫");
    titles.add("搞笑");
    titles.add("精选");

    for (int i = 0; i < titles.size(); i++) {
        mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(i)));
    }
    List<Fragment> fragments = new ArrayList<>();
    for (int i = 0; i < titles.size(); i++) {
        fragments.add(new ListFragment());
    }
    FragmentAdapter mFragmentAdapteradapter =
            new FragmentAdapter(getSupportFragmentManager(), fragments, titles);
    //给ViewPager设置适配器
    mViewPager.setAdapter(mFragmentAdapteradapter);
    //将TabLayout和ViewPager关联起来。
    mTabLayout.setupWithViewPager(mViewPager);
    //给TabLayout设置适配器
    mTabLayout.setTabsFromPagerAdapter(mFragmentAdapteradapter);
}
 
开发者ID:henrymorgen,项目名称:android-advanced-light,代码行数:34,代码来源:TabLayoutActivity.java

示例9: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_viewpager);
  viewPager = (ViewPager) findViewById(R.id.viewPager);
  tabLayout = (TabLayout) findViewById(R.id.tabLayout);

  if (getIntent().getBooleanExtra(KEY_STATEPAGER, false)) {
    viewPager.setAdapter(new MyFragmentStatePagerAdapter(getSupportFragmentManager()));
  } else {
    viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager()));
  }

  tabLayout.setupWithViewPager(viewPager);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ViewPagerActivity.java

示例10: initTabLayout

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void initTabLayout(List<XianduCategory> xianduCategories) {
    TabLayout tabLayout = findView(R.id.tabs);
    ViewPager viewPager = findView(R.id.viewPager);
    setupViewPager(viewPager, xianduCategories);
    viewPager.setOffscreenPageLimit(viewPager.getAdapter().getCount());
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:9,代码来源:ReadingFragment.java

示例11: initTabs

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void initTabs() {
    cFragment = new ChatsFragment();
    uFragment = new UserFragment();
    sFragment = new SearchFragment();
    FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            if (position == 1)
                return uFragment;
            if (position == 2)
                return sFragment;
            return cFragment;
        }

        @Override
        public int getCount() {
            return 3;
        }
    };
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(adapter);
    TabLayout tabLayout = findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.getTabAt(0).setIcon(R.mipmap.icon_messenger);
    tabLayout.getTabAt(1).setIcon(R.drawable.ic_person);
    tabLayout.getTabAt(2).setIcon(R.drawable.ic_search);
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:28,代码来源:MessengerActivity.java

示例12: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_response);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    restTest = (RestTest) getIntent().getSerializableExtra("restTest");
    response = (RemoteResponse) getIntent().getSerializableExtra("response");


    mViewPager = (AdvancedViewPager) findViewById(R.id.container);
    mViewPager.setEnable(false);
    mViewPager.setAdapter(mSectionsPagerAdapter);

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

    int code = response.getStatusCode();
    if (code >= 200 && code <= 299) {
        toolbar.setBackgroundResource(R.color.get);
        tabLayout.setBackgroundResource(R.color.get);
    } else {
        toolbar.setBackgroundResource(R.color.error);
        tabLayout.setBackgroundResource(R.color.error);
    }
    if (-1 == response.getStatusCode()) {
        ab.setTitle(response.getResponseMessage());
    } else {
        ab.setTitle(response.getStatusCode() + " " + response.getResponseMessage());
    }

}
 
开发者ID:Sayi,项目名称:RestClient,代码行数:38,代码来源:ResponseActivity.java

示例13: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    TextView myTitle = (TextView) toolbar.getChildAt(0);
    Typeface tf = Typeface.createFromAsset(getAssets(),getResources().getString(R.string.font_name));
    myTitle.setTypeface(tf,Typeface.BOLD);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    AdView mAdView = (AdView)findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(getResources().getString(R.string.ad_device_test))
            .build();
    mAdView.loadAd(adRequest);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:28,代码来源:MainActivity.java

示例14: onCreateView

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.news_fragment_layout, container, false);
    initData();

    ViewPager viewPager = view.findViewById(R.id.news_view_pager);
    HomeNewsFragmentAdapter adapter = new HomeNewsFragmentAdapter(getChildFragmentManager());
    viewPager.setAdapter(adapter);

    TabLayout tabLayout = view.findViewById(R.id.top_tab_layout);
    tabLayout.setupWithViewPager(viewPager);
    return view;
}
 
开发者ID:zhongjuncoder,项目名称:AggregationNews,代码行数:15,代码来源:NewsFragment.java

示例15: setUpTabViewPager

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void setUpTabViewPager() {
    TabLayout tabLayout = $(R.id.tab);
    mPagerAdapter = new FragmentPagerAdapterBuilder(this)
            .add(new MyScriptListFragment_(), R.string.text_script)
            .add(new DocsFragment_(), R.string.text_tutorial)
            .add(new CommunityFragment_(), R.string.text_community)
            .add(new SampleListFragment_(), R.string.text_sample)
            .add(new TaskManagerFragment_(), R.string.text_manage)
            .build();
    mViewPager.setAdapter(mPagerAdapter);
    tabLayout.setupWithViewPager(mViewPager);
    setUpViewPagerFragmentBehaviors();
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:14,代码来源:MainActivity.java


注:本文中的android.support.design.widget.TabLayout.setupWithViewPager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。