當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。