ernestoyaquello / VerticalStepperForm

Vertical Stepper Form Library for Android. It follows Google Material Design guidelines.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot add a null child view to a ViewGroup

aharoldk opened this issue · comments

`val mySteps = arrayOf("Name", "Email", "Phone Number")
val colorPrimary = ContextCompat.getColor(applicationContext, R.color.colorPrimary)
val colorPrimaryDark = ContextCompat.getColor(applicationContext, R.color.colorPrimaryDark)

    VerticalStepperFormLayout.Builder.newInstance(vertical_stepper_form, mySteps, this, this)
            .primaryColor(colorPrimary)
            .primaryDarkColor(colorPrimaryDark)
            .displayBottomNavigation(true) // It is true by default, so in this case this line is not necessary
            .init()`

i try this code and get cannot add a null child view to a ViewGroup.
can you tell me where it wrong?

You have to add the view to your steps in createStepContentView(int stepNumber)

Like this
@Override public View createStepContentView(int stepNumber) { View view = null; switch (stepNumber) { case 0: view = createFirstStep(); break; case 1: view = createSecondStep(); break; } return view; //and then rerturn the view you created

the createFirstStep is a method which returns the view which then provided to the vertical stepper view group

private View createFirstStep() { // Here we generate programmatically the view that will be added by the system to the step content layout TextView name = new TextView(this)); name.setSingleLine(true); name.setHint(R.string.select_location); return name; }

This issue seems to have been already solved, so I will close it now.