-
Notifications
You must be signed in to change notification settings - Fork 0
Listeners
You have to implement View.OnClickListener interface and provide it to TutorialOptions.Builder#setOnSkipClickListener(OnClickListener). Example:
public class CustomTutorialFragment extends TutorialFragment {
@Override
protected TutorialOptions provideTutorialOptions() {
return newTutorialOptionsBuilder(getContext())
.setOnSkipClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "Skip button clicked", Toast.LENGTH_SHORT).show();
}
})
// setup other configuration ...
.build();
}
}You can listen change page events - just implement OnTutorialPageChangeListener and add listener via TutorialFragment#addOnTutorialPageChangeListener(OnTutorialPageChangeListener). To remove listener use TutorialFragment#removeOnTutorialPageChangeListener(OnTutorialPageChangeListener). In OnTutorialPageChangeListener#onPageChanged(int) method you will receive a page index every time page changes. If you enabled TutorialOptions.Builder#setUseAutoRemoveTutorialFragment(boolean) to true, you will receive TutorialFragment.EMPTY_FRAGMENT_POSITION (or TutorialSupportFragment.EMPTY_FRAGMENT_POSITION if you are using support library) as page index.
public class CustomTutorialFragment extends TutorialFragment
implements OnTutorialPageChangeListener {
private static final String TAG = "CustomTutorialFragment";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addOnTutorialPageChangeListener(this);
}
@Override
public void onPageChanged(int position) {
Log.i(TAG, "onPageChanged: position = " + position);
if (position == TutorialFragment.EMPTY_FRAGMENT_POSITION) {
Log.i(TAG, "onPageChanged: Empty fragment is visible");
}
}
}