Skip to content
ValeryGes edited this page Apr 7, 2017 · 8 revisions

First, add gradle dependency into your build.gradle:

dependencies {
    compile 'com.cleveroad:slidingtutorial:1.0.8'
}

Then the only thing you need is to add a tutorial fragment via FragmentManager.

final TutorialFragment tutorialFragment = TutorialFragment.newInstance(tutorialOptions);
getFragmentManager()
	.beginTransaction()
	.replace(R.id.container, tutorialFragment)
	.commit();

If your fragments extended from android.support.v4.app.Fragment class, here you go:

final TutorialSupportFragment tutorialFragment = TutorialSupportFragment.newInstance(tutorialOptions);
getSupportFragmentManager()
	.beginTransaction()
	.replace(R.id.container, tutorialFragment)
	.commit();

What is tutorialOptions variable? It's an instance of TutorialOptions class that holds all settings of your tutorial. See Configuring your tutorial with TutorialOptions for more details.

Listening for page changes

In some cases you need to get notifications when user navigates through tutorial. You can do it in old good fashion and add a ViewPager.OnPageChangeListener. But if you also enabled infinite scroll, you will receive invalid values of position variable. To get a proper position value you need to add an implementation of OnTutorialPageChangeListener into TutorialFragment#addOnTutorialPageChangeListener(...) method. To remove a listener just call TutorialFragment#removeOnTutorialPageChangeListener(...).

Custom tutorial layout

You can specify custom tutorial layout. All you need is:

  1. Create your own XML layout for tutorial page. See our layout here.
  2. Extend your tutorial fragment from TutorialFragment or TutorialSupportFragment.
  3. Override all this getters and provide proper resource IDs.
  4. ....
  5. Profit

You must always specify ViewPager. All other views are optional.