Вопрос

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>
Это было полезно?

Решение

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top