{"id":6785,"date":"2022-04-05T03:42:44","date_gmt":"2022-04-05T03:42:44","guid":{"rendered":"https:\/\/androiddvlpr.com\/?p=6785"},"modified":"2022-04-05T03:42:45","modified_gmt":"2022-04-05T03:42:45","slug":"android-viewpager-explained-with-example","status":"publish","type":"post","link":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/","title":{"rendered":"Android ViewPager Explained with Example"},"content":{"rendered":"\n<p>Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book. It can be used to display a collection of pages in a linear fashion, or as an aid for navigating between screens in an app. ViewPager is implemented as a subclass of ViewGroup, so it can be used in a layout file just like any other view.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img  loading=\"lazy\"  decoding=\"async\"  width=\"320\"  height=\"569\"  src=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/android-viewpager-used-in-duolingo-1-80x142.gif\"  alt=\"\"  class=\"wp-image-6796 pk-lqip pk-lazyload\"  data-pk-sizes=\"auto\"  data-pk-src=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/android-viewpager-used-in-duolingo-1.gif\" ><figcaption>Android ViewPager used in Duolingo App<\/figcaption><\/figure><\/div>\n\n\n\n<h2 id=\"create-android-viewpager\" class=\"wp-block-heading\">Create Android ViewPager<\/h2>\n\n\n\n<p>To create a ViewPager, add the following to your layout file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;android.support.v4.view.ViewPager \nandroid:id=\"@+id\/viewpager\" \nandroid:layout_width=\"match_parent\" \nandroid:layout_height=\"match_parent\"\/&gt;<\/code><\/pre>\n\n\n\n<h2 id=\"android-viewpager-with-pages-pageadapter\" class=\"wp-block-heading\">Android ViewPager with Pages (PageAdapter)<\/h2>\n\n\n\n<p>To populate the ViewPager with pages, you need to create a PagerAdapter. A <strong>PagerAdapter is responsible for creating and managing the views<\/strong> that will be displayed in the ViewPager. There are a few different ways to create a PagerAdapter. The simplest way is to create an instance of <strong>FragmentPagerAdapter<\/strong>.<\/p>\n\n\n\n<p>To use a FragmentPagerAdapter, <strong>you first need to create a layout file for each fragment that you want to display in the ViewPager<\/strong>. Each fragment should use the same layout file, and the layout should contain a ViewPager widget.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img  loading=\"lazy\"  decoding=\"async\"  width=\"700\"  height=\"624\"  src=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-80x71.png\"  alt=\"Android ViewPager with Pages (PageAdapter)\"  class=\"wp-image-6797 pk-lqip pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 700px) 100vw, 700px\"  data-pk-src=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-700x624.png\"  data-pk-srcset=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-700x624.png 700w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-300x267.png 300w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-768x685.png 768w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-800x713.png 800w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-80x71.png 80w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter-600x535.png 600w, https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png 1116w\" ><figcaption>Android ViewPager with Pages (PageAdapter)<\/figcaption><\/figure><\/div>\n\n\n\n<p>In your activity class, create an instance of FragmentPagerAdapter and pass it the layout file for the fragment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager(), R.layout.fragment_page); \nviewPager.setAdapter(adapter);<\/code><\/pre>\n\n\n\n<p>If you want to use a custom PagerAdapter, you can create your own class that implements the PagerAdapter interface. Your adapter will need to implement two methods: <strong>getItem() and getCount()<\/strong>.<\/p>\n\n\n\n<p>The <strong>getItem() method returns the Fragment<\/strong> that should be displayed for a given position in the ViewPager, and the <strong>getCount() method returns the number of fragments <\/strong>that should be displayed in the ViewPager.<\/p>\n\n\n\n<p>You can also use a PagerTabStrip to navigation between pages in the ViewPager. A <strong>PagerTabStrip contains a list of tabs<\/strong>, each of which corresponds to a page in the ViewPager. To add a PagerTabStrip to your layout, add the following XML:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;android.support.v4.view.PagerTabStrip \nandroid:id=\"@+id\/pager_tab_strip\" \nandroid:layout_width=\"match_parent\" \nandroid:layout_height=\"wrap_content\"\/&gt;<\/code><\/pre>\n\n\n\n<p>In your activity class, add an instance of PagerTabStrip and set it as the tabsProvider for the ViewPager:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>viewPager.setTabsProvider(new PagerTabStrip());<\/code><\/pre>\n\n\n\n<h2 id=\"populate-a-viewpager-with-fragments\" class=\"wp-block-heading\">Populate a ViewPager with fragments<\/h2>\n\n\n\n<p>One way to populate a ViewPager is with fragments. Fragments are reusable pieces of UI that can be combined to create more complex layouts. <strong>To use fragments in a ViewPager, you need to use the FragmentPagerAdapter class.<\/strong> This adapter class knows how to manage fragments for you and populate the ViewPager with them.<\/p>\n\n\n\n<p>There are a few different ways you can create a FragmentPagerAdapter. One way is to create an instance of the adapter directly and specify the fragments you want it to use. Another way is to use the FragmentManager to create the adapter. <\/p>\n\n\n\n<p>The FragmentManager can be used to get a list of all of the fragments in your app, and then you can use that list to create the adapter.<\/p>\n\n\n\n<p>Once you have created a <strong>FragmentPagerAdapter, you need to set it on the ViewPager widget using the setAdapter() method. You can also optionally specify a fragment transition animation using thesetPageTransformer() method. This will cause Android to animate between pages when they are changed.<\/strong><\/p>\n\n\n\n<p>Here&#8217;s an example of how to use a FragmentPagerAdapter in your Android app:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; \n&lt;android.support.v4.view.ViewPager\nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \nandroid:id=\"@+id\/pager\" \nandroid:layout_width=\"match_parent\" \nandroid:layout_height=\"match_parent\"\/&gt; \n\n&lt;!-- This layout will be used to display the pages in the ViewPager --&gt;\n&lt;LinearLayout \nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \nandroid:orientation=\"vertical\" \nandroid:layout_width=\"match_parent\" \nandroid:layout_height=\"wrap_content\"&gt; \n\n&lt;!-- This view will be used to display the current page in the ViewPager --&gt; \n&lt;TextView \nandroid:id=\"@+id\/page_text\" \nandroid:layout_width=\"wrap_content\" \nandroid:layout_height=\"wrap_content\"\/&gt; \n&lt;\/LinearLayout&gt; \n\n&lt;!-- This is the fragment that will be displayed on the first page --&gt; \n&lt;fragment \nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \nandroid:name=\".MyFragment\" \/&gt; \n\n&lt;!-- This is the fragment that will be displayed on the second page --&gt; \n&lt;fragment \nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \nandroid:name=\".AnotherFragment\"\/&gt; \n\n&lt;!-- This is the fragment that will be displayed on the third page --&gt; \n&lt;fragment \nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" \nandroid:name=\".YetAnotherFragment\"\/&gt; \n\n&lt;!-- Android ViewPager code goes here --&gt;<\/code><\/pre>\n\n\n\n<p>In this example, we have a layout file for our ViewPager and three fragments. The first fragment is the one that will be displayed on the first page, the second fragment is the one that will be displayed on the second page, and so on.<\/p>\n\n\n\n<p>To populate the ViewPager, we need to create a FragmentPagerAdapter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class MyPagerAdapter extends FragmentPagerAdapter {\r\n        public List&lt;String> listOfFragmentNames; \r\n\r\n        public MyPagerAdapter(FragmentManager fm, List&lt;String> fragments) {\r\n            super(fm);\r\n            listOfFragmentNames = fragments;\r\n        }\r\n\r\n        @Override\r\n        public Fragment getItem(int position) {\r\n            \/\/return MyFragment.newInstance();\r\n            return Fragment.instantiate(context, listOfFragmentNames.get(position));\r\n\r\n        }\r\n\r\n        @Override\r\n        public CharSequence getPageTitle(int position) {\r\n            \/\/return CONTENT&#91;position % CONTENT.length].toUpperCase();\r\n            return mEntries.get(position % CONTENT.length).toUpperCase();\r\n        }\r\n\r\n        @Override\r\n        public int getCount() {\r\n           \/\/ return CONTENT.length;\r\n            return mEntries.size();\r\n        }\r\n\r\n        @Override\r\n        public int getItemPosition(Object object) {\r\n            return POSITION_NONE;\r\n        }\r\n    }<\/code><\/pre>\n\n\n\n<p>So you have to define a fragment list (These go to the main FragmentActivity) :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>static MyPagerAdapter adapter;<\/code><\/pre>\n\n\n\n<p>and create a list of String of Fragment Names<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fragments.add(FirstFragment.class.getName());\r\nfragments.add(SecondFragment.class.getName());\r\nfragments.add(ThirdFragment.class.getName());\r\n\/\/..etc<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> pager = (ViewPager)findViewById(R.id.viewpager);\r\n adapter = new MyPagerAdapter(getSupportFragmentManager(),fragments);\r\n pager.setAdapter(adapter);<\/code><\/pre>\n\n\n\n<p>Here, we are creating a new Adapter instance and passing in our Activity, the layout file for our pages, and a list of fragments. We then set the adapter on our ViewPager widget.<\/p>\n\n\n\n<h4 id=\"animate-android-viewpager\" class=\"wp-block-heading\">Animate Android ViewPager<\/h4>\n\n\n\n<p>Finally, we can optionally specify a fragment transition animation using thesetPageTransformer() method. This will cause Android to animate between pages when they are changed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>viewPager.setPageTransformer(new Fragment2FragmentPagerTransformer());<\/code><\/pre>\n\n\n\n<p>In this code, we are specifying a new Fragment2FragmentPagerTransformer instance as the page transformer. Android will use this transformer to animate between pages when they are changed.<\/p>\n\n\n\n<p><a href=\"https:\/\/androiddvlpr.com\/learn-to-use-translate-animation-in-android\/\">Learn More about Animating views in Android from link here<\/a><\/p>\n\n\n\n<p>That&#8217;s all there is to using Android ViewPager!<\/p>\n\n\n\n<p>Source: <a href=\"https:\/\/stackoverflow.com\/questions\/16149778\/how-do-i-use-fragmentpageradapter-to-have-tabs-with-different-content\">How do I use FragmentPagerAdapter to have tabs with different content? &#8211; Stack Overflow<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book. It can be used to display a collection of pages in a linear fashion, or as an aid for navigating between screens in an app. \n","protected":false},"author":1,"featured_media":6797,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,60],"tags":[13,256,257,76,75],"class_list":{"0":"post-6785","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-blog","8":"category-build-from-scratch","9":"tag-animation","10":"tag-fragment","11":"tag-fragmentpageradapter","12":"tag-fragments","13":"tag-viewpager"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android ViewPager Explained with Example - Android Dvlpr<\/title>\n<meta name=\"description\" content=\"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android ViewPager Explained with Example - Android Dvlpr\" \/>\n<meta property=\"og:description\" content=\"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Android Dvlpr\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/androiddvlpr\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-05T03:42:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-05T03:42:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1116\" \/>\n\t<meta property=\"og:image:height\" content=\"995\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rishabh Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rishabh Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/\"},\"author\":{\"name\":\"Rishabh Jain\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/#\\\/schema\\\/person\\\/e16d409afce260c84f434a6275463712\"},\"headline\":\"Android ViewPager Explained with Example\",\"datePublished\":\"2022-04-05T03:42:44+00:00\",\"dateModified\":\"2022-04-05T03:42:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/\"},\"wordCount\":716,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/androiddvlpr.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Android-ViewPager-with-Pages-PageAdapter.png\",\"keywords\":[\"Animation\",\"fragment\",\"FragmentPagerAdapter\",\"fragments\",\"viewpager\"],\"articleSection\":[\"Blog\",\"Build from Scratch\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/\",\"url\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/\",\"name\":\"Android ViewPager Explained with Example - Android Dvlpr\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/androiddvlpr.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Android-ViewPager-with-Pages-PageAdapter.png\",\"datePublished\":\"2022-04-05T03:42:44+00:00\",\"dateModified\":\"2022-04-05T03:42:45+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/#\\\/schema\\\/person\\\/e16d409afce260c84f434a6275463712\"},\"description\":\"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#primaryimage\",\"url\":\"https:\\\/\\\/androiddvlpr.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Android-ViewPager-with-Pages-PageAdapter.png\",\"contentUrl\":\"https:\\\/\\\/androiddvlpr.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Android-ViewPager-with-Pages-PageAdapter.png\",\"width\":1116,\"height\":995,\"caption\":\"Android ViewPager with Pages PageAdapter\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/android-viewpager-explained-with-example\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/androiddvlpr.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android ViewPager Explained with Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/#website\",\"url\":\"https:\\\/\\\/androiddvlpr.com\\\/\",\"name\":\"Android Dvlpr\",\"description\":\"Android Tutorials and Libraries to build Apps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/androiddvlpr.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/androiddvlpr.com\\\/#\\\/schema\\\/person\\\/e16d409afce260c84f434a6275463712\",\"name\":\"Rishabh Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g\",\"caption\":\"Rishabh Jain\"},\"url\":\"https:\\\/\\\/androiddvlpr.com\\\/author\\\/appdev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android ViewPager Explained with Example - Android Dvlpr","description":"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/","og_locale":"en_US","og_type":"article","og_title":"Android ViewPager Explained with Example - Android Dvlpr","og_description":"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.","og_url":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/","og_site_name":"Android Dvlpr","article_publisher":"https:\/\/www.facebook.com\/androiddvlpr\/","article_published_time":"2022-04-05T03:42:44+00:00","article_modified_time":"2022-04-05T03:42:45+00:00","og_image":[{"width":1116,"height":995,"url":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","type":"image\/png"}],"author":"Rishabh Jain","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rishabh Jain","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#article","isPartOf":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/"},"author":{"name":"Rishabh Jain","@id":"https:\/\/androiddvlpr.com\/#\/schema\/person\/e16d409afce260c84f434a6275463712"},"headline":"Android ViewPager Explained with Example","datePublished":"2022-04-05T03:42:44+00:00","dateModified":"2022-04-05T03:42:45+00:00","mainEntityOfPage":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/"},"wordCount":716,"commentCount":0,"image":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#primaryimage"},"thumbnailUrl":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","keywords":["Animation","fragment","FragmentPagerAdapter","fragments","viewpager"],"articleSection":["Blog","Build from Scratch"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/","url":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/","name":"Android ViewPager Explained with Example - Android Dvlpr","isPartOf":{"@id":"https:\/\/androiddvlpr.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#primaryimage"},"image":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#primaryimage"},"thumbnailUrl":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","datePublished":"2022-04-05T03:42:44+00:00","dateModified":"2022-04-05T03:42:45+00:00","author":{"@id":"https:\/\/androiddvlpr.com\/#\/schema\/person\/e16d409afce260c84f434a6275463712"},"description":"Android ViewPager is a widget that allows the user to flip through pages of content, similar to a pager or book in a linear fashion.","breadcrumb":{"@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#primaryimage","url":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","contentUrl":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","width":1116,"height":995,"caption":"Android ViewPager with Pages PageAdapter"},{"@type":"BreadcrumbList","@id":"https:\/\/androiddvlpr.com\/android-viewpager-explained-with-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androiddvlpr.com\/"},{"@type":"ListItem","position":2,"name":"Android ViewPager Explained with Example"}]},{"@type":"WebSite","@id":"https:\/\/androiddvlpr.com\/#website","url":"https:\/\/androiddvlpr.com\/","name":"Android Dvlpr","description":"Android Tutorials and Libraries to build Apps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androiddvlpr.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androiddvlpr.com\/#\/schema\/person\/e16d409afce260c84f434a6275463712","name":"Rishabh Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/581f2a547b53e6438d0add58a362189ba30d13f6822b802c3f06cc4b09f2630c?s=96&d=monsterid&r=g","caption":"Rishabh Jain"},"url":"https:\/\/androiddvlpr.com\/author\/appdev\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/androiddvlpr.com\/wp-content\/uploads\/2022\/04\/Android-ViewPager-with-Pages-PageAdapter.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paTNLr-1Lr","_links":{"self":[{"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/posts\/6785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/comments?post=6785"}],"version-history":[{"count":5,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/posts\/6785\/revisions"}],"predecessor-version":[{"id":6800,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/posts\/6785\/revisions\/6800"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/media\/6797"}],"wp:attachment":[{"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/media?parent=6785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/categories?post=6785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androiddvlpr.com\/wp-json\/wp\/v2\/tags?post=6785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}