Java Code Examples for android.support.design.widget.TabLayout#getTabAt()
The following examples show how to use
android.support.design.widget.TabLayout#getTabAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaginationHelper.java From ForPDA with GNU General Public License v3.0 | 6 votes |
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(); } } } }
Example 2
Source File: TransactionActivityTest.java From budget-watch with GNU General Public License v3.0 | 6 votes |
@Test public void bothTabsExists() throws Exception { ActivityController activityController = Robolectric.buildActivity(TransactionActivity.class).create(); Activity activity = (Activity)activityController.get(); activityController.start(); activityController.resume(); TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tabLayout); assertNotNull(tabLayout); assertEquals(2, tabLayout.getTabCount()); TabLayout.Tab expenseTab = tabLayout.getTabAt(0); assertNotNull(expenseTab); String expenseTabTitle = activity.getResources().getString(R.string.expensesTitle); assertEquals(expenseTabTitle, expenseTab.getText().toString()); TabLayout.Tab revenueTab = tabLayout.getTabAt(1); assertNotNull(revenueTab); String revenueTabTitle = activity.getResources().getString(R.string.revenuesTitle); assertEquals(revenueTabTitle, revenueTab.getText().toString()); }
Example 3
Source File: TabLayoutSupport.java From RecyclerViewPager with Apache License 2.0 | 6 votes |
@Override public void OnPageChanged(int oldPosition, int newPosition) { if (mViewPagerRef.get() == null) { return; } if (mViewPagerRef.get() instanceof LoopRecyclerViewPager) { newPosition = ((LoopRecyclerViewPager) mViewPagerRef.get()) .transformToActualPosition(newPosition); } TabLayout tabLayout = this.mTabLayoutRef.get(); if (tabLayout != null && tabLayout.getTabAt(newPosition) != null) { mPageChangeTabSelectingNow = true; tabLayout.getTabAt(newPosition).select(); mPageChangeTabSelectingNow = false; } }
Example 4
Source File: YCRedDotView.java From YCRedDotView with Apache License 2.0 | 5 votes |
/** * 设置支持tabLayout控件 * @param target TabLayout * @param tabIndex 索引 */ public void setTargetView(TabLayout target, int tabIndex) { TabLayout.Tab tabAt = target.getTabAt(tabIndex); View customView = null; if (tabAt != null) { customView = tabAt.getCustomView(); } setTargetView(customView); }
Example 5
Source File: ClearBrowsingDataTabsFragment.java From 365browser with Apache License 2.0 | 5 votes |
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment. View view = inflater.inflate(R.layout.clear_browsing_data_tabs, container, false); // Get the ViewPager and set its PagerAdapter so that it can display items. ViewPager viewPager = (ViewPager) view.findViewById(R.id.clear_browsing_data_viewpager); viewPager.setAdapter( new ClearBrowsingDataPagerAdapter(getFragmentManager(), getActivity())); // Give the TabLayout the ViewPager. TabLayout tabLayout = (TabLayout) view.findViewById(R.id.clear_browsing_data_tabs); tabLayout.setupWithViewPager(viewPager); tabLayout.addOnTabSelectedListener(new TabSelectListener()); int tabIndex = adjustIndexForDirectionality( PrefServiceBridge.getInstance().getLastSelectedClearBrowsingDataTab()); TabLayout.Tab tab = tabLayout.getTabAt(tabIndex); if (tab != null) { tab.select(); } // Remove elevation to avoid shadow between title and tabs. Preferences activity = (Preferences) getActivity(); activity.getSupportActionBar().setElevation(0.0f); return view; }
Example 6
Source File: EditActivity.java From homeassist with Apache License 2.0 | 4 votes |
@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(); }
Example 7
Source File: GroupActivity.java From homeassist with Apache License 2.0 | 4 votes |
@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(); } }); }
Example 8
Source File: CashOutFragment.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
@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; }