本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
};
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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;
}
示例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();
}