Search in sources :

Example 71 with ViewPager

use of android.support.v4.view.ViewPager in project chuck by jgilfelt.

the class TransactionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chuck_activity_transaction);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    title = (TextView) findViewById(R.id.toolbar_title);
    final ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    transactionId = getIntent().getLongExtra(ARG_TRANSACTION_ID, 0);
    getSupportLoaderManager().initLoader(0, null, this);
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 72 with ViewPager

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

Example 73 with ViewPager

use of android.support.v4.view.ViewPager in project SlidingMenu by jfeinstein10.

the class ViewPagerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ViewPager vp = new ViewPager(this);
    vp.setId("VP".hashCode());
    vp.setAdapter(new ColorPagerAdapter(getSupportFragmentManager()));
    setContentView(vp);
    vp.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int position) {
            switch(position) {
                case 0:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
                    break;
                default:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
                    break;
            }
        }
    });
    vp.setCurrentItem(0);
    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
}
Also used : OnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener) ViewPager(android.support.v4.view.ViewPager)

Example 74 with ViewPager

use of android.support.v4.view.ViewPager in project Android-Developers-Samples by johnjohndoe.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set content view (which contains a CheeseListFragment)
    setContentView(R.layout.sample_main);
    // Retrieve the ViewPager from the content view
    ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
    // Set an OnPageChangeListener so we are notified when a new item is selected
    vp.setOnPageChangeListener(mOnPageChangeListener);
    // Finally set the adapter so the ViewPager can display items
    vp.setAdapter(mPagerAdapter);
}
Also used : ViewPager(android.support.v4.view.ViewPager)

Example 75 with ViewPager

use of android.support.v4.view.ViewPager in project ZhihuDailyPurify by izzyleung.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    layoutResID = R.layout.activity_main;
    super.onCreate(savedInstanceState);
    TabLayout tabs = (TabLayout) findViewById(R.id.main_pager_tabs);
    ViewPager viewPager = (ViewPager) findViewById(R.id.main_pager);
    assert tabs != null;
    assert viewPager != null;
    viewPager.setOffscreenPageLimit(PAGE_COUNT);
    MainPagerAdapter adapter = new MainPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    tabs.setupWithViewPager(viewPager);
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_pick_date);
    assert floatingActionButton != null;
    floatingActionButton.setOnClickListener(v -> prepareIntent(PickDateActivity.class));
}
Also used : TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) 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