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


Java TabLayout.setOnTabSelectedListener方法代码示例

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


在下文中一共展示了TabLayout.setOnTabSelectedListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

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

    mViewPagerAdapter = new MyViewPagerAdapter(getActivity());

    ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
    viewPager.setAdapter(mViewPagerAdapter);

    mTabs = (TabLayout) view.findViewById(R.id.tabs);
    mTabs.post(new Runnable() {
        @Override
        public void run() {
            mTabs.setTabsFromPagerAdapter(mViewPagerAdapter);
        }
    });

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabs));
    mTabs.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));

    return view;
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:24,代码来源:NotebookTabsFragment.java

示例2: 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

示例3: onCreate

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

    framework = new App_Framework(this);

    //ACCESS THE PASSED PARAMETERS FROM GUI_adaptr.java
    this.projectUniqueID = getIntent().getStringExtra("project_view_unique_ID");
    this.projectTitle = getIntent().getStringExtra("project_view_title");

    //check if the value of ID and title is null, if so, exit the application and output error message
    if(this.projectUniqueID.isEmpty() || this.projectTitle.isEmpty())
    {
        finish();
        Log.e("Unexpected Error", "Project Title or ID is NULL");
        System.exit(0);
    }

    setTitle(this.projectTitle);

    Bundle bundle = new Bundle();
    bundle.putString("title", this.projectTitle);
    bundle.putString("id", this.projectUniqueID);
    mainView.setArguments(bundle);

    projectViewFragmentAdapter = new projectView_fragmentPagerAdapter(getSupportFragmentManager());

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

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

    //this disables the back button at the upper left screen
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
 
开发者ID:FYP17-4G,项目名称:Aardvark,代码行数:40,代码来源:GUI_project_view.java


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