Example usage for android.support.v4.view CustomViewPager addOnPageChangeListener

List of usage examples for android.support.v4.view CustomViewPager addOnPageChangeListener

Introduction

In this page you can find the example usage for android.support.v4.view CustomViewPager addOnPageChangeListener.

Prototype

public void addOnPageChangeListener(OnPageChangeListener listener) 

Source Link

Document

Add a listener that will be invoked whenever the page changes or is incrementally scrolled.

Usage

From source file:com.parse.loginsample.layoutoverride.SampleProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_profile);

    //titleTextView = (TextView) findViewById(R.id.profile_title);
    //emailTextView = (TextView) findViewById(R.id.profile_email);
    //nameTextView = (TextView) findViewById(R.id.profile_name);
    userProfilePictureView = (ProfilePictureView) findViewById(R.id.profile_picture);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if ((currentUser != null) && currentUser.isAuthenticated()) {
        makeMeRequest();/*from w ww.ja v a 2s  .c om*/
    }
    //setContentView(R.layout.activity_profile);
    //k2oMfrGIR+N4VQ6AAy8iOA|UIDw
    //k2oMfrGIR+N4VQ6AAy8i0AlUIDw=
    //XlnE2PbYPysS2sTYxJfimYcGMVI=
    // Get the ViewPager and set it's PagerAdapter so that it can display items

    // Give the TabLayout the ViewPager

    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.addTab(tabLayout.newTab().setText("Home"));
    tabLayout.addTab(tabLayout.newTab().setText("Profile"));
    tabLayout.addTab(tabLayout.newTab().setText("Swipe"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    final CustomViewPager viewPager = (CustomViewPager) findViewById(R.id.viewpager);
    viewPager.setPagingEnabled(false);
    viewPager.setAdapter(
            new SampleFragmentPagerAdapter(getSupportFragmentManager(), SampleProfileActivity.this));
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });
    //loginOrLogoutButton = (Button) findViewById(R.id.login_or_logout_button);
    //titleTextView.setText(R.string.profile_title_logged_in);

    /*loginOrLogoutButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        if (currentUser != null) {
          // User clicked to log out.
          ParseUser.logOut();
          currentUser = null;
          showProfileLoggedOut();
        } else {
          // User clicked to log in.
            
        }
      }
    });*/
}