Pager

Additional

Language
Java
Version
V1.1 (Feb 21, 2019)
Created
Feb 19, 2019
Updated
Mar 9, 2019
Owner
Pradyuman Dixit (Pradyuman7)
Contributor
Pradyuman Dixit (Pradyuman7)
1
Activity
Badge
Generate
Download
Source code
APK file

Commercial

Pager

🔥 An android library to get simple menu options to 💪. Inspired by AndroidResideMenu.

GIF

AndroidPub(Medium) Post

You can read the AndroidPub post about this library, the perks it provides and other details here.

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
  repositories {
   ...
   maven { url 'https://www.jitpack.io' }
  }
 }

Dependency

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies 
         implementation 'com.github.Pradyuman7:Pager:V1.1'
 }

Usage

  • Add the layout in your XML file for the activity, like this:
<?xml version="1.0" encoding="utf-8"?>
<merge
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.pd.cards.Main2Activity"
    tools:ignore="all"
    tools:showIn="@layout/activity_main2">

    <com.pd.pager.PagerLayout
        android:id="@+id/rl_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        app:num="five"/>
</merge>
<com.pd.pager.PagerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent">

</com.pd.pager.PagerLayout>

  • Configure the layout and add the fragments like this:
    PagerLayout pager = findViewById(R.id.rl_main);
    
            List<String> titleList =newArrayList<>();
            titleList.add("Page1");
            titleList.add("Page2");
            titleList.add("Page3");
            titleList.add("Page4");
            titleList.add("Page5");
    
            if(pager ==null)
                Log.i("Pager_Null","Pager is null");
    
    
            pager.setTitles(titleList);
    
    
            fragments.add(newPage1());
            fragments.add(newPage2());
            fragments.add(newPage3());
            fragments.add(newPage4());
            fragments.add(newPage5());
    
            FragmentPagerAdapter adapter =newFragmentPagerAdapter(getSupportFragmentManager()) {
                @OverridepublicFragmentgetItem(intposition) {
                    return fragments.get(position);
                }
    
                @OverridepublicintgetCount() {
                    return fragments.size();
                }
            };
    
            pager.setAdapter(adapter);
    • See the app code to know more about this.