Closed shadab-saif closed 2 years ago
You can programmatically change the stepperView.widgetColor
to the new color in the StepperNavListener.onCompleted()
overrien method.
You can programmatically change the
stepperView,widgetColor
to the new color in theStepperNavListener.onCompleted()
overrien method.
lateinit var stepper: StepperNavigationView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_registration)
val navHostFragment =
supportFragmentManager.findFragmentById(R.id.frame_stepper) as NavHostFragment
val navController = navHostFragment.navController
val stepper = findViewById<StepperNavigationView>(R.id.stepper)
stepper.setupWithNavController(navController)
}
override fun onCompleted() {
stepper.widgetColor = R.color.purple_200
}
override fun onStepChanged(step: Int) {
TODO("Not yet implemented")
}
here is my code but it is not working
stepperView.widgetColor
takes in a ColorInt
and not a ColorRes
. You'll need to use context.getColor(R.color.purple_200)
or ContextCompat.getColor(context, R.color.purple_200)
instead
stepperView.widgetColor
takes in aColorInt
and not aColorRes
. You'll need to usecontext.getColor(R.color.purple_200)
orContextCompat.getColor(context, R.color.purple_200)
instead
stepper.widgetColor = ContextCompat.getColor(applicationContext, R.color.purple_200) (not working)
Just to confirm, do you want to do this when it's completed or when it gets to the last step.
Because, if it is the latter, you need to put the widget color change in the onStepChanged()
function.
e.g
override fun onStepChanged(step: Int) {
if (step == noOfSteps) stepper.widgetColor = ContextCompat.getColor(applicationContext, R.color.purple_200)
}
These both override function are not even call I have used toast message just to check these function are working or not, and I don't even see the toast.
Have you connected the listener to the stepperView
with stepperView.stepperNavListener = this
I have not connected the listener but now it is working when connected the listener, But it does not give me what I want, I want only completed widget step color change but it will change the complete stepper color.
Sorry @shadab-saif, unfortunately, the library doesn't include this functionality. But you can always fork the project and add this,
I want to change the color of widget when the step is competed, How I can achieve it.