allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
Add the dependency
dependencies {
compile 'com.github.fcannizzaro:material-stepper:1.2.2'
}
Extend one of these classes TextStepper
, ProgressStepper
, DotStepper
, TabStepper
set stepper title
add a step
set primary color (Toolbar/ Progress & Dot & Tab Circle color )
set status bar & text color
set timeout (milliseconds) of error message
use FragmentStatePagerAdapter for ViewPager instead of FragmentPagerAdapter
show initial "previous" button (first step)
limit user path (user has to complete previous step before move to next)
show previous button on the left
disable user touch on tabs (prevent click)
use alternative tab style
- classic
- alternative
get stepper toolbar
called when 'complete' button is pressed
public class Sample extends TabStepper {
@Override
protected void onCreate(Bundle savedInstanceState) {
/*
...
methods
...
*/
// call super at the end
super.onCreate(savedInstanceState);
}
Extend AbstractStep
override step name
override error message (HTML supported)
override if is optional [Default = false]
override condition to move to next step [Default = true]
called when a step is visible
called when next button is pressed
called when previous button is pressed
public class StepSample extends AbstractStep {
// step name
@Override
public String name() {
return "Step title";
}
// step optional title (default: "Optional")
@Override
public String optional() {
return "Optional subtitle";
}
// set step optional or not (default: false)
@Override
public boolean isOptional() {
return true;
}
// override only if step is limited by condition
@Override
public boolean nextIf() {
return i > 5;
}
// error showed on change next step ( see nextIf )
@Override
public String error() {
return "<b>Condition</b>";
}
// do something when step is visible
@Override
public void onStepVisible() {
super.onStepVisible();
}
}
get available bundle for current step
get bundle for specific step and set your data
get bundle for last step
// get bundle for step 3
Bundle data = getStepDataFor(3);
data.putInt("test",5);
Save data returned in onActivityResult
Bundle data = mStepper.getExtras();
Overwrite these strings for support multilanguage / custom titles
<string name="ms_prev">PREV</string>
<string name="ms_next">NEXT</string>
<string name="ms_end">COMPLETE</string>
<string name="ms_continue">CONTINUE</string>
<string name="ms_optional">Optional</string>
<string name="ms_text_step">Step $current of $total</string>