문제

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