Retrieving ViewPager2

Report a typo

You have a ViewPager2 which is declared as follows:

<androidx.viewpager2.widget.ViewPager2
    android:id="@+id/page_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Now you want to use it with your Kotlin code. Write the line that is missing in the following snippet to retrieve your ViewPager2:

val viewPager2 = ... //Something is missing here!
val pagerAdapter = YourAdapterName()
viewPager2.adapter = pagerAdapter
Enter a short text
___

Create a free account to access the full topic