Search in sources :

Example 1 with MapFragment

use of com.rengwuxian.rxjavasamples.module.map_2.MapFragment in project RxJavaSamples by rengwuxian.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolBar);
    viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {

        @Override
        public int getCount() {
            return 6;
        }

        @Override
        public Fragment getItem(int position) {
            switch(position) {
                case 0:
                    return new ElementaryFragment();
                case 1:
                    return new MapFragment();
                case 2:
                    return new ZipFragment();
                case 3:
                    return new TokenFragment();
                case 4:
                    return new TokenAdvancedFragment();
                case 5:
                    return new CacheFragment();
                default:
                    return new ElementaryFragment();
            }
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position) {
                case 0:
                    return getString(R.string.title_elementary);
                case 1:
                    return getString(R.string.title_map);
                case 2:
                    return getString(R.string.title_zip);
                case 3:
                    return getString(R.string.title_token);
                case 4:
                    return getString(R.string.title_token_advanced);
                case 5:
                    return getString(R.string.title_cache);
                default:
                    return getString(R.string.title_elementary);
            }
        }
    });
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TokenFragment(com.rengwuxian.rxjavasamples.module.token_4.TokenFragment) ZipFragment(com.rengwuxian.rxjavasamples.module.zip_3.ZipFragment) FragmentPagerAdapter(android.support.v13.app.FragmentPagerAdapter) MapFragment(com.rengwuxian.rxjavasamples.module.map_2.MapFragment) CacheFragment(com.rengwuxian.rxjavasamples.module.cache_6.CacheFragment) Fragment(android.app.Fragment) TokenFragment(com.rengwuxian.rxjavasamples.module.token_4.TokenFragment) ZipFragment(com.rengwuxian.rxjavasamples.module.zip_3.ZipFragment) CacheFragment(com.rengwuxian.rxjavasamples.module.cache_6.CacheFragment) MapFragment(com.rengwuxian.rxjavasamples.module.map_2.MapFragment) ElementaryFragment(com.rengwuxian.rxjavasamples.module.elementary_1.ElementaryFragment) TokenAdvancedFragment(com.rengwuxian.rxjavasamples.module.token_advanced_5.TokenAdvancedFragment) TokenAdvancedFragment(com.rengwuxian.rxjavasamples.module.token_advanced_5.TokenAdvancedFragment) ElementaryFragment(com.rengwuxian.rxjavasamples.module.elementary_1.ElementaryFragment)

Aggregations

Fragment (android.app.Fragment)1 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)1 CacheFragment (com.rengwuxian.rxjavasamples.module.cache_6.CacheFragment)1 ElementaryFragment (com.rengwuxian.rxjavasamples.module.elementary_1.ElementaryFragment)1 MapFragment (com.rengwuxian.rxjavasamples.module.map_2.MapFragment)1 TokenFragment (com.rengwuxian.rxjavasamples.module.token_4.TokenFragment)1 TokenAdvancedFragment (com.rengwuxian.rxjavasamples.module.token_advanced_5.TokenAdvancedFragment)1 ZipFragment (com.rengwuxian.rxjavasamples.module.zip_3.ZipFragment)1