I'm developing an Android application but I've encountered a problem when dealing with ViewStub. In particular in my imus.java class I have this code in the onCreate method:
Stub = (ViewStub) findViewById(R.id.imu_toinclude);
inflated_initialization = Stub.inflate();
In the corresponding imus.xml I have:
<ViewStub
android:id="@+id/imu_toinclude"
android:layout="@layout/initialization_imu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inflatedId="@+id/initialization_2" />
where initialization_imu is the name of the layout I would like ti inflate. The error I get is:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.ViewStub.inflate()' on a null object reference
Hope that someone can help me