use of android.support.v4.view.ViewPager in project UltimateAndroid by cymcsg.
the class MaterialTabsWithIconsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_tab_activity_main);
res = this.getResources();
// init toolbar (old action bar)
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
this.setSupportActionBar(toolbar);
tabHost = (MaterialTabHost) this.findViewById(R.id.materialTabHost);
pager = (ViewPager) this.findViewById(R.id.viewpager);
// init view pager
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < pagerAdapter.getCount(); i++) {
tabHost.addTab(tabHost.newTab().setIcon(getIcon(i)).setTabListener(this));
}
//tabHost.setAccentColor(Color.BLUE);
}
use of android.support.v4.view.ViewPager in project philm by chrisbanes.
the class BasePhilmTabFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_viewpager, container, false);
mAdapter = new TabPagerAdapter(getChildFragmentManager());
mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
mViewPager.setAdapter(mAdapter);
mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_minor));
mTabLayout = (TabLayout) view.findViewById(R.id.viewpager_tabs);
mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
final Fragment fragment = mAdapter.getItem(tab.getPosition());
if (fragment instanceof ListFragment) {
((ListFragment) fragment).smoothScrollTo(0);
}
}
});
if (savedInstanceState != null) {
mCurrentItem = savedInstanceState.getInt(SAVE_SELECTED_TAB);
}
return view;
}
use of android.support.v4.view.ViewPager in project cheesesquare by chrisbanes.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
ab.setDisplayHomeAsUpEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null) {
setupDrawerContent(navigationView);
}
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.
the class PagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View result = inflater.inflate(R.layout.pager, container, false);
ViewPager pager = (ViewPager) result.findViewById(R.id.pager);
pager.setAdapter(buildAdapter());
return (result);
}
use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.
the class ViewPagerIndicatorActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(buildAdapter());
}
Aggregations