use of android.support.v4.view.ViewPager in project ExpandingPager by qs-lll.
the class ExpandingPagerFactory method getCurrentFragment.
public static ExpandingFragment getCurrentFragment(ViewPager viewPager) {
if (viewPager.getAdapter() instanceof ExpandingViewPagerAdapter) {
ExpandingViewPagerAdapter adapter = (ExpandingViewPagerAdapter) viewPager.getAdapter();
Fragment fragment = adapter.getCurrentFragment();
if (fragment instanceof ExpandingFragment) {
return (ExpandingFragment) fragment;
}
}
return null;
}
use of android.support.v4.view.ViewPager in project material by rey5137.
the class TabPageIndicator method setViewPager.
/**
* Set the ViewPager associate with this indicator view.
* @param view The ViewPager view.
*/
public void setViewPager(@Nullable ViewPager view) {
if (mViewPager == view)
return;
if (mViewPager != null) {
mViewPager.removeOnPageChangeListener(this);
PagerAdapter adapter = mViewPager.getAdapter();
if (adapter != null)
adapter.unregisterDataSetObserver(mObserver);
}
mViewPager = view;
if (mViewPager != null) {
PagerAdapter adapter = mViewPager.getAdapter();
if (adapter == null)
throw new IllegalStateException("ViewPager does not have adapter instance.");
adapter.registerDataSetObserver(mObserver);
mViewPager.addOnPageChangeListener(this);
notifyDataSetChanged();
onPageSelected(mViewPager.getCurrentItem());
} else
mTabContainer.removeAllViews();
}
use of android.support.v4.view.ViewPager in project android-support-v4-googlemaps by petedoyle.
the class ActionBarTabsPager method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.pager);
setContentView(mViewPager);
final ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
mTabsAdapter = new TabsAdapter(this, mViewPager);
mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null);
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
}
}
use of android.support.v4.view.ViewPager in project android-support-v4-googlemaps by petedoyle.
the class FragmentNestingPagerSupport method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.pager);
setContentView(mViewPager);
final ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
mTabsAdapter = new TabsAdapter(this, mViewPager);
mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Tabs"), FragmentTabsFragment.class, null);
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
}
}
use of android.support.v4.view.ViewPager in project Meizhi by drakeet.
the class SmoothAppBarLayout method initViews.
protected void initViews() {
if (mViewPagerId > 0) {
vViewPager = (ViewPager) getRootView().findViewById(mViewPagerId);
} else {
int i = 0;
ViewGroup parent = (ViewGroup) getParent();
View child;
for (int z = parent.getChildCount(); i < z; i++) {
child = parent.getChildAt(i);
if (child instanceof ViewPager) {
vViewPager = (ViewPager) child;
break;
}
}
}
}
Aggregations