android.support.design.widget.TabLayout#getTabCount ( )源码实例Demo

下面列出了android.support.design.widget.TabLayout#getTabCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ForPDA   文件: PaginationHelper.java
public void updatePagination(Pagination newPagination) {
    this.pagination = newPagination;
    for (TabLayout tabLayout : tabLayouts) {
        if (pagination.getAll() <= 1) {
            tabLayout.setVisibility(View.GONE);
            return;
        }
        tabLayout.setVisibility(View.VISIBLE);
        boolean prevDisabled = pagination.getCurrent() <= 1;
        boolean nextDisabled = pagination.getCurrent() == pagination.getAll();
        TabLayout.Tab tab;
        int tag;
        for (int i = 0; i < tabLayout.getTabCount(); i++) {
            tab = tabLayout.getTabAt(i);
            if (tab == null || tab.getTag() == null) return;
            tag = (Integer) tab.getTag();
            if ((tag) == TAG_SELECT) continue;
            if (tab.getIcon() != null) {
                if ((tag == TAG_FIRST || tag == TAG_PREV) ? prevDisabled : nextDisabled)
                    tab.getIcon().setColorFilter(colorFilter);
                else
                    tab.getIcon().clearColorFilter();
            }
        }
    }
}
 
源代码2 项目: IslamicLibraryAndroid   文件: LibraryFragment.java
private void makTabsFixed(@NonNull TabLayout tabLayout) {
    ViewGroup slidingTabStrip = (ViewGroup) tabLayout.getChildAt(0);
    int tabCount = tabLayout.getTabCount();
    for (int i = 0; i < tabCount; i++) {
        View tab = slidingTabStrip.getChildAt(i);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams();
        layoutParams.weight = 1;
        tab.setLayoutParams(layoutParams);
    }
}
 
源代码3 项目: homeassist   文件: EditActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit);

    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        Crashlytics.log("group: " + bundle.getString("group", "empty"));
        mGroup = CommonUtil.inflate(bundle.getString("group"), Group.class);
        if (mGroup == null) {
            discardAndFinish();
            return;
        }
    } else {
        discardAndFinish();
        return;
    }

    mSharedPref = getAppController().getSharedPref();
    mProgressDialog = CommonUtil.getProgressDialog(this);
    mProgressDialog.setContent(getString(R.string.progress_saving));

    //Setup Toolbar
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(getString(R.string.title_edit));
    }

    TabLayout mTabLayout = findViewById(R.id.tabs);
    mTabLayout.setSelectedTabIndicatorHeight(CommonUtil.pxFromDp(this, 4f));
    mTabLayout.addTab(mTabLayout.newTab().setText(mGroup.getFriendlyName()));
    if (mGroup.hasMdiIcon()) {
        int tabIndex = mTabLayout.getTabCount() - 1;
        TabLayout.Tab currentTab = mTabLayout.getTabAt(tabIndex);
        if (currentTab != null) {
            View tab = LayoutInflater.from(this).inflate(R.layout.custom_tab, mTabLayout, false);

            TextView mdiText = tab.findViewById(R.id.text_mdi);
            TextView nameText = tab.findViewById(R.id.text_name);
            mdiText.setText(MDIFont.getIcon(mGroup.attributes.icon));
            nameText.setText(mGroup.getFriendlyName());
            nameText.setVisibility(View.VISIBLE);
            currentTab.setCustomView(tab);
        }
    }

    //mDatabaseManager = DatabaseManager.getInstance(this);
    //getSupportLoaderManager().initLoader(1, null, this);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showAddDialog();
        }
    });

    setupRecyclerView();
}
 
源代码4 项目: homeassist   文件: GroupActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit);

    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        Crashlytics.log("group: " + bundle.getString("group", "empty"));
        mGroup = CommonUtil.inflate(bundle.getString("group"), Group.class);
    } else {
        finish();
        return;
    }

    mSharedPref = getAppController().getSharedPref();
    mProgressDialog = CommonUtil.getProgressDialog(this);
    mProgressDialog.setContent(getString(R.string.progress_saving));

    //Setup Toolbar
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(getString(R.string.title_edit));
    }

    TabLayout mTabLayout = findViewById(R.id.tabs);
    mTabLayout.setSelectedTabIndicatorHeight(CommonUtil.pxFromDp(this, 4f));
    mTabLayout.addTab(mTabLayout.newTab().setText(mGroup.getFriendlyName()));
    if (mGroup.hasMdiIcon()) {
        int tabIndex = mTabLayout.getTabCount() - 1;
        TabLayout.Tab currentTab = mTabLayout.getTabAt(tabIndex);
        if (currentTab != null) {
            View tab = LayoutInflater.from(this).inflate(R.layout.custom_tab, mTabLayout, false);

            TextView mdiText = tab.findViewById(R.id.text_mdi);
            TextView nameText = tab.findViewById(R.id.text_name);
            mdiText.setText(MDIFont.getIcon(mGroup.attributes.icon));
            nameText.setText(mGroup.getFriendlyName());
            nameText.setVisibility(View.VISIBLE);
            currentTab.setCustomView(tab);
        }
    }

    //mDatabaseManager = DatabaseManager.getInstance(this);
    //getSupportLoaderManager().initLoader(1, null, this);
    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showAddDialog();
        }
    });
}
 
源代码5 项目: iGap-Android   文件: CashOutFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view =  inflater.inflate(R.layout.fragment_cash_out, container, false);

    ViewGroup rootView = view.findViewById(R.id.rootView);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackgroundColor(Color.parseColor(WalletActivity.primaryColor));
    }
    appBar = view.findViewById(R.id.app_bar);
    appBar.setTitle(getString(isCashOut ? R.string.cash_out_paygear : R.string.charge_paygear));
    appBar.setToolBarBackgroundRes(R.drawable.app_bar_back_shape,true);
    appBar.getBack().getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(WalletActivity.primaryColor),PorterDuff.Mode.SRC_IN));
    appBar.showBack();

    TabLayout tabLayout = view.findViewById(R.id.tab_layout);
    mPager = view.findViewById(R.id.view_pager);
    mPagerAdapter = new WalletPagerAdapter(getChildFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    tabLayout.setupWithViewPager(mPager);

    if (isCashOut) {
        mPager.setCurrentItem(1);
    }

    for (int i = 0; i < tabLayout.getTabCount(); i++) {
        TabLayout.Tab tab = tabLayout.getTabAt(i);
        if (tab != null) {
            TextView textView = new TextView(getContext());
            textView.setId(android.R.id.text1);
            textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            textView.setTextColor(Color.WHITE);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            textView.setTypeface(Typefaces.get(getContext(), Typefaces.IRAN_YEKAN_REGULAR));

            tab.setCustomView(textView);
        }
    }

    return view;
}