Search in sources :

Example 51 with ViewPager

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;
}
Also used : ExpandingFragment(com.qslll.library.fragments.ExpandingFragment) Fragment(android.support.v4.app.Fragment) ExpandingFragment(com.qslll.library.fragments.ExpandingFragment)

Example 52 with ViewPager

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 53 with ViewPager

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));
    }
}
Also used : ViewPager(android.support.v4.view.ViewPager) ActionBar(android.app.ActionBar)

Example 54 with ViewPager

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));
    }
}
Also used : ViewPager(android.support.v4.view.ViewPager) ActionBar(android.app.ActionBar)

Example 55 with ViewPager

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;
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Aggregations

ViewPager (android.support.v4.view.ViewPager)246 View (android.view.View)95 PagerAdapter (android.support.v4.view.PagerAdapter)55 Fragment (android.support.v4.app.Fragment)44 TabLayout (android.support.design.widget.TabLayout)37 TextView (android.widget.TextView)35 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)34 Toolbar (android.support.v7.widget.Toolbar)30 Bundle (android.os.Bundle)28 ViewGroup (android.view.ViewGroup)27 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)17 ActionBar (android.support.v7.app.ActionBar)15 RecyclerView (android.support.v7.widget.RecyclerView)11 ViewTreeObserver (android.view.ViewTreeObserver)9 AdapterView (android.widget.AdapterView)9 LinearLayout (android.widget.LinearLayout)9 UiController (android.support.test.espresso.UiController)8