Search in sources :

Example 16 with ViewPager

use of androidx.viewpager.widget.ViewPager in project SmoothRefreshLayout by dkzwm.

the class TestNestedWithViewPagerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_nested_with_viewpager);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    ViewPager viewPager = findViewById(R.id.viewPager_test_nested_with_viewPager);
    mFragments = new ArrayList<>();
    for (int sColor : sColors) {
        mFragments.add(NestedPageFragment.newInstance(sColor));
    }
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), mFragments);
    viewPager.setAdapter(adapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_nested_with_viewPager);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < mFragments.size(); i++) {
                        NestedPageFragment fragment = mFragments.get(i);
                        fragment.updateData();
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }

        @Override
        public void onLoadingMore() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < mFragments.size(); i++) {
                        NestedPageFragment fragment = mFragments.get(i);
                        fragment.appendData();
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
    mRefreshLayout.autoRefresh(false);
}
Also used : NestedPageFragment(me.dkzwm.widget.srl.sample.ui.fragment.NestedPageFragment) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar) MaterialSmoothRefreshLayout(me.dkzwm.widget.srl.MaterialSmoothRefreshLayout) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 17 with ViewPager

use of androidx.viewpager.widget.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(androidx.viewpager.widget.ViewPager)

Example 18 with ViewPager

use of androidx.viewpager.widget.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(androidx.viewpager.widget.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(androidx.appcompat.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 19 with ViewPager

use of androidx.viewpager.widget.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(androidx.viewpager.widget.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(androidx.appcompat.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 20 with ViewPager

use of androidx.viewpager.widget.ViewPager in project MPAndroidChart by PhilJay.

the class SimpleChartDemo method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_awesomedesign);
    setTitle("SimpleChartDemo");
    ViewPager pager = findViewById(R.id.pager);
    pager.setOffscreenPageLimit(3);
    PageAdapter a = new PageAdapter(getSupportFragmentManager());
    pager.setAdapter(a);
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle("This is a ViewPager.");
    b.setMessage("Swipe left and right for more awesome design examples!");
    b.setPositiveButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    b.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) ViewPager(androidx.viewpager.widget.ViewPager)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)68 View (android.view.View)24 Intent (android.content.Intent)12 TabLayout (com.google.android.material.tabs.TabLayout)12 Toolbar (androidx.appcompat.widget.Toolbar)11 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)9 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)9 ImageView (android.widget.ImageView)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 Bundle (android.os.Bundle)6 PagerAdapter (androidx.viewpager.widget.PagerAdapter)6 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)5 LinearInterpolator (android.view.animation.LinearInterpolator)4 NonNull (androidx.annotation.NonNull)4 FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4