you can put any value in "CURRENT_STEP_POSITION_KEY"
I tried the same process but my first step is empty
here is my adapter
private val pages = SparseArray<Step>()
override fun createStep(@IntRange(from = 0)position: Int): Step {
//val step = StepFragmentSample()
//val b = Bundle()
//b.putInt(CURRENT_STEP_POSITION_KEY, position)
//step.setArguments(b)
//return step
val b = Bundle()
val CURRENT_STEP_POSITION_KEY = "CURRENT_STEP_POSITION_KEY"
b.putInt(CURRENT_STEP_POSITION_KEY, position)
return when (position) {
2 -> {
//FormAddBashDocumentFragment()
val addBashDocumentFragment = FormAddBashDocumentFragment()
addBashDocumentFragment.setArguments(b)
return addBashDocumentFragment
}
1 -> {
//FormAddClaimsFragment()
val addClaimsFragment = FormAddClaimsFragment()
addClaimsFragment.setArguments(b)
return addClaimsFragment
}
0 -> {
//FormAddClaimBatchesFragment()
val addClaimBatchesFragment = FormAddClaimBatchesFragment()
addClaimBatchesFragment.setArguments(b)
return addClaimBatchesFragment
}
else -> throw IllegalArgumentException("Unsupported position: " + position)
}
}
override fun getCount(): Int {
return 3
}
override fun findStep(position: Int): Step? {
return if (pages.size() > 0) pages.get(position) else null
}
override fun instantiateItem(container: ViewGroup, position: Int): View {
var step: Step? = pages.get(position)
if (step == null) {
step = createStep(position)
pages.put(position, step)
}
val stepView = step as View
container.addView(stepView)
return stepView
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
container.removeView(`object` as View)
}
override fun getViewModel(@IntRange(from = 0)position: Int): StepViewModel {
//Override this method to set Step title for the Tabs, not necessary for other stepper types
val builder = StepViewModel.Builder(context)
.setTitle("New batch")
when (position) {
0 -> builder
.setTitle("Batch")
.setEndButtonLabel("claim")
.setBackButtonLabel("Cancel")
.setBackButtonStartDrawableResId(StepViewModel.NULL_DRAWABLE)
1 -> builder
.setTitle("claim")
.setBackButtonLabel("Back to batch")
2 -> builder
.setTitle("Documents")
.setBackButtonLabel("Back to claim")
.setEndButtonLabel("I'm done!")
else -> throw java.lang.IllegalArgumentException("Unsupported position: $position")
}
return builder.create()
}