Search in sources :

Example 36 with ViewPager

use of android.support.v4.view.ViewPager in project danci by ling0322.

the class TabPageIndicator method setViewPager.

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

Example 37 with ViewPager

use of android.support.v4.view.ViewPager in project fresco by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new MyPagerAdapter(pager.getChildCount());
    pager.setAdapter(mAdapter);
}
Also used : ViewPager(android.support.v4.view.ViewPager)

Example 38 with ViewPager

use of android.support.v4.view.ViewPager in project quickstart-android by firebase.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create the adapter that will return a fragment for each section
    mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        private final Fragment[] mFragments = new Fragment[] { new RecentPostsFragment(), new MyPostsFragment(), new MyTopPostsFragment() };

        private final String[] mFragmentNames = new String[] { getString(R.string.heading_recent), getString(R.string.heading_my_posts), getString(R.string.heading_my_top_posts) };

        @Override
        public Fragment getItem(int position) {
            return mFragments[position];
        }

        @Override
        public int getCount() {
            return mFragments.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentNames[position];
        }
    };
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    // Button launches NewPostActivity
    findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, NewPostActivity.class));
        }
    });
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Intent(android.content.Intent) RecentPostsFragment(com.google.firebase.quickstart.database.fragment.RecentPostsFragment) Fragment(android.support.v4.app.Fragment) MyPostsFragment(com.google.firebase.quickstart.database.fragment.MyPostsFragment) MyTopPostsFragment(com.google.firebase.quickstart.database.fragment.MyTopPostsFragment) View(android.view.View) MyTopPostsFragment(com.google.firebase.quickstart.database.fragment.MyTopPostsFragment) RecentPostsFragment(com.google.firebase.quickstart.database.fragment.RecentPostsFragment) TabLayout(android.support.design.widget.TabLayout) MyPostsFragment(com.google.firebase.quickstart.database.fragment.MyPostsFragment)

Example 39 with ViewPager

use of android.support.v4.view.ViewPager in project ZoomHeader by githubwing.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mZoomHeader = (ZoomHeaderView) findViewById(R.id.zoomHeader);
    mViewPager.setAdapter(new Adapter());
    mViewPager.setOffscreenPageLimit(4);
    CtrlLinearLayoutManager layoutManager = new CtrlLinearLayoutManager(this);
    //未展开禁止滑动
    layoutManager.setScrollEnabled(false);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(new ListAdapter());
    mRecyclerView.setAlpha(0);
    mBottomView = (RelativeLayout) findViewById(R.id.rv_bottom);
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 40 with ViewPager

use of android.support.v4.view.ViewPager in project android-pathview by geftimov.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
    final ScreenSlidePagerAdapter screenSlidePagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    viewpager.setAdapter(screenSlidePagerAdapter);
    viewpager.setPageTransformer(true, new CustomTransformer());
}
Also used : 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