I want dynamically add ViewPagers to Fragment. For example I created xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvHeader"
android:textColor="@color/black"
android:textSize="18sp"
android:layout_margin="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/vpUsers"
android:layout_width="match_parent"
android:layout_height="85dp" />
</LinearLayout>
and inflate views with it. But ViewPagers shows incorrect. Look like problem related with same ids for ViewPagers. When I removed android:id="@+id/vpUsers"
I got error:
java.lang.IllegalStateException: ViewPager with adapter com.raybytes.SMSAddict.adapters.UserSectionAdapter$MyFragmentPagerAdapter@11a219d0 requires a view id
Same problem if I create ViewPagers programatically because ids are requeired but manually setting of ids is dangerous.
How can I inflate or programatically create few ViewPagers with different ids? (number of ViewPagers is unknown)