-
Notifications
You must be signed in to change notification settings - Fork 377
Quick Start
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.
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(...)
.
You can specify custom tutorial layout. All you need is:
- Create your own XML layout for tutorial page. See our layout here.
- Extend your tutorial fragment from
TutorialFragment
orTutorialSupportFragment
. - Override all this getters and provide proper resource IDs.
- ....
- Profit
You must always specify ViewPager
. All other views are optional.