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


Java TabLayout.getTabCount方法代码示例

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


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

示例1: setupViewPager

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
public void setupViewPager () {
    CustomViewPager viewPager = (CustomViewPager) findViewById(R.id.view_pager);
    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());

    if (viewPager != null) {
        viewPager.setPagingEnabled(false);
        viewPager.setAdapter(pagerAdapter);
    }

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    if (mTabLayout != null) {
        mTabLayout.setupWithViewPager(viewPager);

        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            if (tab != null)
                tab.setCustomView(pagerAdapter.getTabView(i));
        }

        mTabLayout.getTabAt(1).getCustomView().setSelected(true);
    }
}
 
开发者ID:techstar-cloud,项目名称:techstar-shop,代码行数:23,代码来源:MainActivity.java

示例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 = (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);
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:21,代码来源:MainActivity.java

示例3: onCreate

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

  ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
  viewPager.setAdapter(new StickerPagerAdapter(getSupportFragmentManager(), this));

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

  for (int i=0;i<tabLayout.getTabCount();i++) {
    tabLayout.getTabAt(i).setIcon(TAB_TITLES[i]);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:StickerSelectActivity.java

示例4: makTabsFixed

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void makTabsFixed(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);
    }
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:11,代码来源:LibraryFragment.java

示例5: theme

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
private void theme(View root) {
        int colorPrimary = getResources().getColor(R.color.colorPrimary);
        int accentColor = getResources().getColor(R.color.colorAccent);
        boolean isPrimaryDark = true;
        int contentColor = GeneralUtils.resolveColor(getContext(), android.R.attr.textColorPrimaryInverse, 0);

        root.findViewById(R.id.top_bar_house).setBackgroundColor(colorPrimary);
        ((TextView) root.findViewById(R.id.single_storage_item_text_view)).setTextColor(contentColor);

        TabLayout tabLayout = (TabLayout) root.findViewById(R.id.tab_layout);
        tabLayout.setBackgroundColor(colorPrimary);
        tabLayout.setTabTextColors(ColorUtil.withAlpha(contentColor, .75f), contentColor);
        tabLayout.setSelectedTabIndicatorColor(contentColor);
        try {
            for (int i = 0; i < tabLayout.getTabCount(); i++) {
                TabLayout.Tab tab = tabLayout.getTabAt(i);
                Field fTabView = TabLayout.Tab.class.getDeclaredField("mView");
                fTabView.setAccessible(true);
                View tabView = (View) fTabView.get(tab);
                GeneralUtils.setBackgroundDrawable(tabView, MaterialValueHelper.getSelectableItemBackground(getActivity(), isPrimaryDark, false));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


        TintHelper.setTint((ImageView) root.findViewById(R.id.up_button), GeneralUtils.resolveColor(getActivity(), android.R.attr.textColorPrimaryInverse, 0));
        ((TextView) root.findViewById(R.id.cancel)).setTextColor(accentColor);
        ((TextView) root.findViewById(R.id.choose)).setTextColor(accentColor);

//        ATH.setStatusbarColor(d.getWindow(), ColorUtil.darkenColor(colorPrimary));
    }
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:33,代码来源:FolderPickerDialog.java

示例6: process

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
public void process(@NonNull Context context, @Nullable String key, @NonNull View view, @NonNull String suffix) {
    final TabLayout tl = (TabLayout) view;
    final ColorResult result = getColorFromSuffix(context, key, view, suffix);
    if (result == null) return;
    final int color = result.getColor();

    if (mTextMode) {
        tl.setTabTextColors(ATEUtil.adjustAlpha(color, UNFOCUSED_ALPHA), color);
    } else if (mIndicatorMode) {
        tl.setSelectedTabIndicatorColor(color);

        final ColorStateList sl = new ColorStateList(new int[][]{
                new int[]{-android.R.attr.state_selected},
                new int[]{android.R.attr.state_selected}
        },
                new int[]{
                        ATEUtil.adjustAlpha(color, UNFOCUSED_ALPHA),
                        color
                });
        for (int i = 0; i < tl.getTabCount(); i++) {
            final TabLayout.Tab tab = tl.getTabAt(i);
            if (tab != null && tab.getIcon() != null)
                tab.setIcon(TintHelper.createTintedDrawable(tab.getIcon(), sl));
        }
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:28,代码来源:TabLayoutTagProcessor.java

示例7: onCreate

import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_voice);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    CustomViewPager viewPager = (CustomViewPager) findViewById(R.id.view_pager);
    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());

    if (viewPager != null) {
        viewPager.setPagingEnabled(false);
        viewPager.setAdapter(pagerAdapter);
    }

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    if (mTabLayout != null) {
        mTabLayout.setupWithViewPager(viewPager);

        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            if (tab != null)
                tab.setCustomView(pagerAdapter.getTabView(i));
        }

        mTabLayout.getTabAt(1).getCustomView().setSelected(true);
    }
}
 
开发者ID:tortuvshin,项目名称:health,代码行数:28,代码来源:VoiceActivity.java

示例8: onCreate

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

    Log.d(TAG, "Package Name - " + getApplicationContext().getPackageName());

    // Create a new dispatcher using the Google Play driver.
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
    Job myJob = dispatcher.newJobBuilder()
            .setService(MonolithFetchService.class)
            .setRecurring(true)
            .setTrigger(Trigger.executionWindow(SYNC_INTERVAL, SYNC_INTERVAL + SYNC_FLEXTIME))
            .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
            .setTag("update-job")
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .setLifetime(Lifetime.FOREVER)
            .build();

    dispatcher.mustSchedule(myJob);

    // Obtain the FirebaseAnalytics instance.
    FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
    tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));

    // Create the adapter that will return a fragment for each of the two
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(),
            tabLayout.getTabCount());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.setupWithViewPager(mViewPager);
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:44,代码来源:MainActivity.java

示例9: onCreate

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



        mAuth = FirebaseAuth.getInstance();
//        mAuth.signOut();
        dbr_users = FirebaseDatabase.getInstance().getReference().getRoot().child("users");

        // fragment aufsetzen
        ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
        MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
        if (viewPager != null)
            viewPager.setAdapter(pagerAdapter);

        mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
        if (mTabLayout != null) {
            mTabLayout.setupWithViewPager(viewPager);

            for (int i = 0; i < mTabLayout.getTabCount(); i++) {
                TabLayout.Tab tab = mTabLayout.getTabAt(i);
                if (tab != null)
                    tab.setCustomView(pagerAdapter.getTabView(i));
            }

            mTabLayout.getTabAt(0).getCustomView().setSelected(true);
        }


        // Authentifizierungsmodul
        mAuthListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null) {
                    // User is signed in
                    Log.d("LoginTry", "onAuthStateChanged:signed_in:" + user.getUid());
                    getInformationFromFB(user.getUid());
                } else {
                    // User is signed out
                    Log.d("LoginTry", "onAuthStateChanged:signed_out");
                    startActivity(new Intent(MainActivity.this, LoginActivity.class));
                }
                // ...
            }
        };


    }
 
开发者ID:burliEnterprises,项目名称:chapp-messenger,代码行数:52,代码来源:MainActivity.java


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