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


Java TabLayout.OnTabSelectedListener方法代码示例

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


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

示例1: initFields

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void initFields() {
    mTabItems = new ArrayList<>();
    mAdapter = new ViewPagerAdapter(((AppCompatActivity) mContext).getSupportFragmentManager(), mTabItems);
    mViewPager.setAdapter(mAdapter);

    mTabSelectedColorListener = new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            mToolbar.setBackgroundColor(mTabItems.get(tab.getPosition()).getTabColor());
            mTabLayout.setBackgroundColor(mTabItems.get(tab.getPosition()).getTabColor());
            mTabLayout.setTabTextColors(mTabNormalTextColor, mTabSelectedTextColor);
            mTabLayout.setSelectedTabIndicatorColor(mTabIndicatorColor);
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    };
    mTabLayout.addOnTabSelectedListener(mTabSelectedColorListener);
}
 
开发者ID:StupidL,项目名称:TabPagerLayout,代码行数:27,代码来源:TabPagerLayout.java

示例2: addOnTabSelectedListener

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
public TabPagerLayout addOnTabSelectedListener(TabLayout.OnTabSelectedListener listener) {
    mTabLayout.addOnTabSelectedListener(listener);
    return this;
}
 
开发者ID:StupidL,项目名称:TabPagerLayout,代码行数:5,代码来源:TabPagerLayout.java

示例3: setOnTabSelectedListener

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
public void setOnTabSelectedListener(TabLayout.OnTabSelectedListener listener){
    mTabListener = listener;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:4,代码来源:CategoryDropDownView.java

示例4: onActivityCreated

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

    MainActivity activity = (MainActivity) getActivity();
    if (activity == null) throw new AssertionError("Activity is null");

    // MainActivity's layout is guaranteed to be inflated until onCreate returns.
    TabLayout layout = activity.findViewById(R.id.tab_layout);
    onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {}

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {}

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            jumpToTop();
        }
    };
    layout.addOnTabSelectedListener(onTabSelectedListener);

    /* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
     * guaranteed to be set until then.
     * Use a modified scroll listener that both loads more notifications as it goes, and hides
     * the compose button on down-scroll. */
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
    preferences.registerOnSharedPreferenceChangeListener(this);
    hideFab = preferences.getBoolean("fabHide", false);
    scrollListener = new EndlessOnScrollListener(layoutManager) {
        @Override
        public void onScrolled(RecyclerView view, int dx, int dy) {
            super.onScrolled(view, dx, dy);

            ActionButtonActivity activity = (ActionButtonActivity) getActivity();
            FloatingActionButton composeButton = activity.getActionButton();

            if (composeButton != null) {
                if (hideFab) {
                    if (dy > 0 && composeButton.isShown()) {
                        composeButton.hide(); // hides the button if we're scrolling down
                    } else if (dy < 0 && !composeButton.isShown()) {
                        composeButton.show(); // shows it if we are scrolling up
                    }
                } else if (!composeButton.isShown()) {
                    composeButton.show();
                }
            }
        }

        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            NotificationsFragment.this.onLoadMore();
        }
    };

    recyclerView.addOnScrollListener(scrollListener);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:60,代码来源:NotificationsFragment.java


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