Search in sources :

Example 66 with ViewPager

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

Example 67 with ViewPager

use of android.support.v4.view.ViewPager in project SmartTabLayout by ogaclejapan.

the class DemoLikeMediumActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_like_a_medium);
    Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    demo.setup(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
}
Also used : FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 68 with ViewPager

use of android.support.v4.view.ViewPager in project SmartTabLayout by ogaclejapan.

the class DemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    demo.setup(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
}
Also used : FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 69 with ViewPager

use of android.support.v4.view.ViewPager in project Android-Universal-Image-Loader by nostra13.

the class ImagePagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fr_image_pager, container, false);
    ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager);
    pager.setAdapter(new ImageAdapter(getActivity()));
    pager.setCurrentItem(getArguments().getInt(Constants.Extra.IMAGE_POSITION, 0));
    return rootView;
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Example 70 with ViewPager

use of android.support.v4.view.ViewPager in project CircleIndicator by ongakuer.

the class CustomAnimationFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ViewPager viewpager = (ViewPager) view.findViewById(R.id.viewpager);
    CircleIndicator indicator = (CircleIndicator) view.findViewById(R.id.indicator);
    viewpager.setAdapter(new SamplePagerAdapter());
    indicator.setViewPager(viewpager);
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(android.support.v4.view.ViewPager) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Aggregations

ViewPager (android.support.v4.view.ViewPager)235 View (android.view.View)94 PagerAdapter (android.support.v4.view.PagerAdapter)55 Fragment (android.support.v4.app.Fragment)40 TabLayout (android.support.design.widget.TabLayout)34 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)34 TextView (android.widget.TextView)34 Toolbar (android.support.v7.widget.Toolbar)30 Bundle (android.os.Bundle)27 ViewGroup (android.view.ViewGroup)27 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)20 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)19 Intent (android.content.Intent)14 ActionBar (android.support.v7.app.ActionBar)13 RecyclerView (android.support.v7.widget.RecyclerView)10 ViewTreeObserver (android.view.ViewTreeObserver)10 AdapterView (android.widget.AdapterView)9 LinearLayout (android.widget.LinearLayout)9 UiController (android.support.test.espresso.UiController)8