Question

I am trying the code from the answer of this question: dynamically add and remove view to viewpager

I copied the code but inflater at the following line can't be resolved.

FrameLayout v0 = (FrameLayout) inflater.inflate (R.layout.fragment_schema, null);

This is my xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
</FrameLayout>
Was it helpful?

Solution

Your inflater cannot be resolved ? It means you have not initialized or even declared the variable in your code, the code you copied from the other question said "do other initialization", that was one of them that was not showed. You can do so like this :

LayoutInflater inflater = (LayoutInflater)context.getSystemService
      (Context.LAYOUT_INFLATER_SERVICE);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top