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