我想在 android 中实现 Vertical Stepper Library。但是出了点问题,它显示一个错误: 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();
}
Gradle 中添加的库:
compile 'com.ernestoyaquello.stepperform:vertical-stepper-form:0.9.9'
XML 文件如下所示:
<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>