use of android.support.v4.view.PagerAdapter in project musicbrainz-android by jdamcd.
the class ReleaseActivity method configurePager.
private void configurePager() {
pagerAdapter = new ReleasePagerAdapter(getSupportFragmentManager());
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(pagerAdapter);
TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(pager);
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
}
use of android.support.v4.view.PagerAdapter in project FastDev4Android by jiangqqlmj.
the class TabPageIndicator method setViewPager.
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.PagerAdapter in project ProductTour by matrixxun.
the class ProductTour3Activity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
setContentView(R.layout.activity_tutorial);
skip = Button.class.cast(findViewById(R.id.skip));
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
endTutorial();
}
});
next = ImageButton.class.cast(findViewById(R.id.next));
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pager.setCurrentItem(pager.getCurrentItem() + 1, true);
}
});
done = Button.class.cast(findViewById(R.id.done));
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
endTutorial();
}
});
pager = (ViewPager) findViewById(R.id.pager);
pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setPageTransformer(true, new CrossfadePageTransformer());
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == NUM_PAGES - 2 && positionOffset > 0) {
if (isOpaque) {
pager.setBackgroundColor(Color.TRANSPARENT);
isOpaque = false;
}
} else {
if (!isOpaque) {
pager.setBackgroundColor(getResources().getColor(R.color.primary_material_light));
isOpaque = true;
}
}
}
@Override
public void onPageSelected(int position) {
setIndicator(position);
if (position == NUM_PAGES - 2) {
skip.setVisibility(View.GONE);
next.setVisibility(View.GONE);
done.setVisibility(View.VISIBLE);
} else if (position < NUM_PAGES - 2) {
skip.setVisibility(View.VISIBLE);
next.setVisibility(View.VISIBLE);
done.setVisibility(View.GONE);
} else if (position == NUM_PAGES - 1) {
endTutorial();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
buildCircles();
}
use of android.support.v4.view.PagerAdapter in project ProductTour by matrixxun.
the class ProductTourActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
setContentView(R.layout.activity_tutorial);
skip = Button.class.cast(findViewById(R.id.skip));
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
endTutorial();
}
});
next = ImageButton.class.cast(findViewById(R.id.next));
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pager.setCurrentItem(pager.getCurrentItem() + 1, true);
}
});
done = Button.class.cast(findViewById(R.id.done));
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
endTutorial();
}
});
pager = (ViewPager) findViewById(R.id.pager);
pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setPageTransformer(true, new CrossfadePageTransformer());
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == NUM_PAGES - 2 && positionOffset > 0) {
if (isOpaque) {
pager.setBackgroundColor(Color.TRANSPARENT);
isOpaque = false;
}
} else {
if (!isOpaque) {
pager.setBackgroundColor(getResources().getColor(R.color.primary_material_light));
isOpaque = true;
}
}
}
@Override
public void onPageSelected(int position) {
setIndicator(position);
if (position == NUM_PAGES - 2) {
skip.setVisibility(View.GONE);
next.setVisibility(View.GONE);
done.setVisibility(View.VISIBLE);
} else if (position < NUM_PAGES - 2) {
skip.setVisibility(View.VISIBLE);
next.setVisibility(View.VISIBLE);
done.setVisibility(View.GONE);
} else if (position == NUM_PAGES - 1) {
endTutorial();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
buildCircles();
}
use of android.support.v4.view.PagerAdapter in project MaterialTabs by neokree.
the class IconTabActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icons);
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.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// 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));
}
}
Aggregations