com.ogaclejapan.smarttablayout.SmartTabLayout Java Examples
The following examples show how to use
com.ogaclejapan.smarttablayout.SmartTabLayout.
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: MainActivity.java From RemoteControlView with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewPager viewPager = this.findViewById(R.id.viewpager); SmartTabLayout viewPagerTab = this.findViewById(R.id.viewpagertab); FragmentPagerItems pages = new FragmentPagerItems(this); pages.add(FragmentPagerItem.of("功能键", DemoFragment.class)); pages.add(FragmentPagerItem.of("音量键", DemoFragment1.class)); pages.add(FragmentPagerItem.of("播放键", DemoFragment.class)); pages.add(FragmentPagerItem.of("数字键", DemoFragment.class)); FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages); viewPager.setAdapter(adapter); viewPagerTab.setViewPager(viewPager); remoteControlView = this.findViewById(R.id.rcv); }
Example #2
Source File: MainActivity.java From text_converter with GNU General Public License v3.0 | 6 votes |
private void bindView() { mCoordinatorLayout = findViewById(R.id.container); String text = getTextFromAnotherApp(); ViewPager viewPager = findViewById(R.id.view_pager); PagerAdapter adapter = getPageAdapter(text); viewPager.setOffscreenPageLimit(adapter.getCount()); viewPager.setAdapter(adapter); viewPager.addOnPageChangeListener(this); ((SmartTabLayout) findViewById(R.id.tab_layout)).setViewPager(viewPager); //attach listener hide/show keyboard KeyBoardEventListener keyBoardEventListener = new KeyBoardEventListener(this); mCoordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(keyBoardEventListener); mDrawerLayout = findViewById(R.id.drawer_layout); mNavigationView = findViewById(R.id.nav_view); ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.desc_open_drawer, R.string.desc_close_drawer); mDrawerLayout.addDrawerListener(drawerToggle); drawerToggle.syncState(); mNavigationView.setNavigationItemSelectedListener(this); }
Example #3
Source File: MainActivity.java From phphub-android with Apache License 2.0 | 6 votes |
protected void setupTabView() { final LayoutInflater inflater = LayoutInflater.from(this); final int[] tabIcons = {R.drawable.ic_recommended, R.drawable.ic_topics, R.drawable.ic_wiki, R.drawable.ic_me}; FragmentPagerItems pages = FragmentPagerItems.with(this) .add(R.string.recommended, RecommendedFragment.class) .add(R.string.topics, TopicsFragment.class) .add(R.string.wiki, WikiFragment.class) .add(R.string.me, MeFragment.class) .create(); FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter( getSupportFragmentManager(), pages); viewPager.setOffscreenPageLimit(pages.size()); viewPager.setAdapter(adapter); viewpagerTab.setCustomTabView(new SmartTabLayout.TabProvider() { @Override public View createTabView(ViewGroup container, int position, PagerAdapter pagerAdapter) { View view = inflater.inflate(R.layout.custom_tab_icon, container, false); ImageView iconView = (ImageView) view.findViewById(R.id.iv_icon); iconView.setBackgroundResource(tabIcons[position % tabIcons.length]); return view; } }); viewpagerTab.setViewPager(viewPager); }
Example #4
Source File: HomeFragment.java From Newslly with MIT License | 5 votes |
private void setupViewPager(ViewPager viewPager,View view) { ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager()); adapter.addFragment(new FeedFragment(), "Feed"); adapter.addFragment(new TopHeadlinesFragment(), "Top headlines"); adapter.addFragment(new SearchFragment(),"Search"); viewPager.setAdapter(adapter); SmartTabLayout viewPagerTab = (SmartTabLayout) view.findViewById(R.id.viewpagertab); SimpleTabProvider tabProvider = new SimpleTabProvider(getActivity().getApplicationContext(),R.layout.custom_tab,R.id.CustomTabText,R.id.CustomTabImage); viewPagerTab.setCustomTabView(tabProvider); viewPagerTab.setViewPager(viewPager); viewPager.setOffscreenPageLimit(3); }
Example #5
Source File: MainActivity.java From ChatApp with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Action bar related Toolbar toolbar = findViewById(R.id.main_app_bar); toolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(toolbar); getSupportActionBar().setTitle("ChatApp"); // Fragments handler using SmartTabLayout FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter( getSupportFragmentManager(), FragmentPagerItems.with(this) .add("Requests", RequestsFragment.class) .add("Chat", ChatFragment.class) .add("Friends", FriendsFragment.class) .create()); ViewPager viewPager = findViewById(R.id.viewpager); viewPager.setAdapter(adapter); viewPager.setCurrentItem(1); SmartTabLayout viewPagerTab = findViewById(R.id.viewpagertab); viewPagerTab.setViewPager(viewPager); }
Example #6
Source File: FavouritesFragment.java From PopCorn with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_favourites, container, false); mSmartTabLayout = (SmartTabLayout) view.findViewById(R.id.tab_view_pager_fav); mViewPager = (ViewPager) view.findViewById(R.id.view_pager_fav); mViewPager.setAdapter(new FavouritesPagerAdapter(getChildFragmentManager(), getContext())); mSmartTabLayout.setViewPager(mViewPager); return view; }
Example #7
Source File: MainActivity.java From Musync with MIT License | 5 votes |
private void setupViewPager(ViewPager viewPager) { ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); adapter.addFragment(new HomeFragment(),"Home"); adapter.addFragment(new SongsFragment(), "Songs"); adapter.addFragment(new AlbumsFragment(),"Albums"); adapter.addFragment(new FavsFragment(), "Favourites"); adapter.addFragment(new PlaylistsFragment(), "Playlist"); adapter.addFragment(new SyncPlayFragment(), "Sync n Play"); viewPager.setAdapter(adapter); SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab); SimpleTabProvider tabProvider = new SimpleTabProvider(getApplicationContext(),R.layout.custom_tab,R.id.CustomTabText); viewPagerTab.setCustomTabView(tabProvider); viewPagerTab.setViewPager(viewPager); viewPager.setOffscreenPageLimit(5); }
Example #8
Source File: MainActivity.java From adjustablelayout with Apache License 2.0 | 5 votes |
private void init(){ mTabs = (SmartTabLayout) findViewById(R.id.tabs); mainTabFragmentAdapter = new MainTabFragmentAdapter(getSupportFragmentManager(),this); mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setAdapter(mainTabFragmentAdapter); mTabs.setViewPager(mViewPager); mViewPager.setOffscreenPageLimit(mainTabFragmentAdapter.getCount()); headerLayout = (LinearLayout) findViewById(R.id.ll_header_layout); initAppBarLayout(); }
Example #9
Source File: AbsTopNavigationFragment.java From Leisure with GNU Lesser General Public License v3.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { parentView = View.inflate(getContext(), R.layout.layout_top_navigation,null); viewPager = (ViewPager) parentView.findViewById(R.id.inner_viewpager); smartTabLayout = (SmartTabLayout) getActivity().findViewById(R.id.tab_layout); smartTabLayout.setVisibility(View.VISIBLE); pagerAdapter = initPagerAdapter(); viewPager.setAdapter(pagerAdapter); smartTabLayout.setViewPager(viewPager); return parentView; }
Example #10
Source File: TopActivity.java From Qiitanium with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); FragmentManager fm = getFragmentManager(); View header = findViewById(R.id.header); View headerImage = findViewById(R.id.header_image); headerHelper = new ParallaxHeaderHelper.Builder(header, headerImage) .setMinHeight(getDimensionPixelSize(R.dimen.header_min_height)) .setElevation(getDimensionPixelSize(R.dimen.header_elevation)) .create(); SlidingUpPanelLayout slidingUpPanel = ViewUtils.findById(this, R.id.panel); panelHelper = new SlidingUpPanelHelper(slidingUpPanel); TextView title = ViewUtils.findById(this, R.id.title); title.setText(R.string.label_articles); viewPagerAdapter = new FragmentPagerItemAdapter(fm, FragmentPagerItems.with(this) .add(R.string.tab_new, ArticleListFragment.class) .add(R.string.tab_following, ComingSoonScrollableFragment.class) .create()); viewPager = ViewUtils.findById(this, R.id.article_top_viewpager); viewPager.setAdapter(viewPagerAdapter); SmartTabLayout viewPagerTab = ViewUtils.findById(this, R.id.viewpagertab); viewPagerTab.setCustomTabView(R.layout.view_tab, R.id.view_tab_text); viewPagerTab.setViewPager(viewPager); viewPagerTab.setOnPageChangeListener(onPageChangeListener); TextView tagTitle = ViewUtils.findById(this, R.id.tag_top_title); ViewPager tagViewPager = ViewUtils.findById(this, R.id.tag_top_viewpager); tagViewPager.setAdapter(new FragmentPagerItemAdapter(fm, FragmentPagerItems.with(this) .add(R.string.tab_popular, TagListFragment.class) .add(R.string.tab_following, ComingSoonFragment.class) .create())); SmartTabLayout tagViewPagerTab = ViewUtils.findById(this, R.id.tag_top_viewpagertab); tagViewPagerTab.setViewPager(tagViewPager); topMenu = ViewUtils.findById(this, R.id.overlay_top); topMenu.bindTo(this); TypefaceHelper.typeface(title); TypefaceHelper.typeface(tagTitle); TypefaceHelper.typeface(viewPagerTab); TypefaceHelper.typeface(tagViewPagerTab); }