Search in sources :

Example 6 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project leo-app by LCA311.

the class WrapperQRActivity method onCreate.

/*    private ZXingScannerView scV;
    public static Button scan;
    private final int MY_PERMISSIONS_REQUEST_USE_CAMERA = 0;
    private boolean runningScan; */
@Override
protected void onCreate(Bundle savedInstanceState) {
    /*   super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wrapper_qr); */
    //---- START TOOLBAR ---- //
    Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
    //        runningScan = false;
    setSupportActionBar(myToolbar);
    //If it's stupid, but it works it's not stupid
    getSupportActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\">" + getString(R.string.toolbar_title) + "</font>"));
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    //---- ENDE TOOLBAR ---- //
    //---- START TABS ---- //
    mViewPager = (ViewPager) findViewById(R.id.pager);
    FragmentPagerAdapter adapt = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            if (position == 0)
                //QRActivity ist ein Fragment trotz des Namens
                return new QRActivity();
            else
                //ScanActivity ist ein Fragment trotz des Namens
                return new ScanActivity();
        }

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

        @Override
        public CharSequence getPageTitle(int position) {
            if (position == 0)
                return getString(R.string.toolbar_qr);
            else
                return getString(R.string.toolbar_scan);
        }
    };
    mViewPager.setAdapter(adapt);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(mViewPager);
//---- ENDE TABS ---- //
/*        sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
        sqlh = new SQLiteHandler(getApplicationContext());

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                scan.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        scan();
                    }
                });
            }
        }, 100); */
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) TabLayout(android.support.design.widget.TabLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 7 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project ride-read-android by Ride-Read.

the class LoginActivity method initViewPager.

private void initViewPager() {
    mFragments = new ArrayList<>(2);
    mFragments.add(new LoginFragment());
    mFragments.add(new RegisterFragment());
    FragmentPagerAdapter fpa = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }
    };
    mViewpagerTabView.setAdapter(fpa);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter)

Example 8 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project RxBus by ViTess.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.main_bt).setOnClickListener(this);
    findViewById(R.id.main_bt_void).setOnClickListener(this);
    findViewById(R.id.main_bt_tag1).setOnClickListener(this);
    findViewById(R.id.main_bt_tag2).setOnClickListener(this);
    findViewById(R.id.main_bt_tag3).setOnClickListener(this);
    vp = (ViewPager) findViewById(R.id.main_vp);
    arrayList.add(f1);
    arrayList.add(f2);
    adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return arrayList.get(position);
        }

        @Override
        public int getCount() {
            return arrayList.size();
        }
    };
    vp.setAdapter(adapter);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.main_fl, f3);
    transaction.commit();
    RxBus.register(this);
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) SuppressLint(android.annotation.SuppressLint)

Example 9 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project ViewPagerIndicator by JakeWharton.

the class SampleTabsDefault method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_tabs);
    FragmentPagerAdapter adapter = new GoogleMusicAdapter(getSupportFragmentManager());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
    indicator.setViewPager(pager);
}
Also used : TabPageIndicator(com.viewpagerindicator.TabPageIndicator) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Example 10 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project AndroidDevelop by 7449.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rg_group);
    imageView = (ImageView) findViewById(R.id.iv_line);
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);
    ivWidth = (dm.widthPixels / 3);
    viewPager.addOnPageChangeListener(this);
    radioGroup.setOnCheckedChangeListener(this);
    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return ViewPagerFragment.startFragment(position);
        }

        @Override
        public int getCount() {
            return 3;
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) DisplayMetrics(android.util.DisplayMetrics) Fragment(android.support.v4.app.Fragment) Display(android.view.Display)

Aggregations

FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)29 Fragment (android.support.v4.app.Fragment)23 ViewPager (android.support.v4.view.ViewPager)8 View (android.view.View)5 Intent (android.content.Intent)3 TabLayout (android.support.design.widget.TabLayout)3 TabPageIndicator (com.viewpagerindicator.TabPageIndicator)3 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 Toolbar (android.support.v7.widget.Toolbar)2 TextView (android.widget.TextView)2 PageIndicator (com.viewpagerindicator.PageIndicator)2 SuppressLint (android.annotation.SuppressLint)1 Fragment (android.app.Fragment)1 Bundle (android.os.Bundle)1 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 ListFragment (android.support.v4.app.ListFragment)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 OnPageChangeListener (android.support.v4.view.ViewPager.OnPageChangeListener)1 RecyclerView (android.support.v7.widget.RecyclerView)1