0

I want to implement Vertical Stepper Library in android. But something goes wrong, it shows an error: Caused by java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stepper);

    int colorPrimary = ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary);
    int colorPrimaryDark = ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark);
    String[] stepsTitles = getResources().getStringArray(R.array.steps_titles);

    // Finding the view
    verticalStepperForm = (VerticalStepperFormLayout) findViewById(R.id.vertical_stepper_form);

    // Setting up and initializing the form
    VerticalStepperFormLayout.Builder.newInstance(verticalStepperForm, stepsTitles,this, this)
            .primaryColor(colorPrimary)
            .primaryDarkColor(colorPrimaryDark)
            .displayBottomNavigation(true)
            .init();
}

Library Added in Gradle:

compile 'com.ernestoyaquello.stepperform:vertical-stepper-form:0.9.9'

Xml file looks like:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".StepperExampleActivity">

<ernestoyaquello.com.verticalstepperform.VerticalStepperFormLayout
    android:id="@+id/vertical_stepper_form"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"/>

</RelativeLayout>
Rohit Gurjar
  • 437
  • 4
  • 12

1 Answers1

1

Sorry for very late Reply.I just saw the post. and i cannot comment on this post.

First have you gone through (https://github.com/ernestoyaquello/vertical-stepper-form) the complete document and followed all the steps like implemented VerticalStepperForm.

if yes than have you created a view and passed it in the createStepContentView.

@Override
public View createStepContentView(int stepNumber) {
    View view = null;
    switch (stepNumber) {
        case 0:
            view = createNameStep();
            break;
        case 1:
            view = createEmailStep();
            break;
        case 2:
            view = createPhoneNumberStep();
            break;
    }
    return view;
}

private View createEmailStep() {
    // In this case we generate the view by inflating a XML file
    LayoutInflater inflater = LayoutInflater.from(getBaseContext());
    LinearLayout emailLayoutContent = (LinearLayout) inflater.inflate(R.layout.email_step_layout, null, false);
    email = (EditText) emailLayoutContent.findViewById(R.id.email);
    ...
    return emailLayoutContent;
}

R.layout.email_step_layout you have to create this xml file and then you might not get this issue.

Shreyash Khole
  • 560
  • 4
  • 10