SPager

Additional

Language
Kotlin
Version
1.1.1 (Jun 18, 2018)
Created
Dec 19, 2017
Updated
Jun 24, 2018
Owner
Alfian Yusuf Abdullah (alfianyusufabdullah)
Contributor
Alfian Yusuf Abdullah (alfianyusufabdullah)
1
Activity
Badge
Generate
Download
Source code
APK file

Blurb

Fast ViewPager Library

Add Dependencies

  1. Add it in your root build.gradle at the end of repositories:
repositories {
 ...
  maven { url 'https://jitpack.io' }
}
  1. on module app build.gradle
implementation 'com.github.alfianyusufabdullah:spager:1.1.1'

TODO

  • Use AppCompat & Design Library
  • Jangan lupa baca Bismillah
  • Harus jomblo

Layout

first add this code on your layout

<com.alfianyusufabdullah.SPager
   android:id="@+id/mainPage"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

Java Code

add this on your Activity/Fragment

  SPager sPager = findViewById(...);
  
  sPager.initFragmentManager(getSupportFragmentManager());
  sPager.addPages("One" , new PageOne());
  sPager.addPages("Two" , new PageTwo());
  sPager.addPages("Three" , new PageThree());
  sPager.build();

if you wanna add tablayout just add this

sPager.addTabLayout(tabLayout);

and finally code like this

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  TabLayout tabLayout = findViewById(R.id.mainTab);
 
  SPager sPager = findViewById(...);
  sPager.initFragmentManager(getSupportFragmentManager());
  sPager.addPages("One" , new FragmentOne());
  sPager.addPages("Two" , new FragmentTwo());
  sPager.addPages("Three" , new FragmentThree());
  sPager.addTabLayout(tabLayout);
  sPager.build();
}

Kotlin Code

in kotlin you just add this on your Activity or Fragment

  initViewPager(R.id.mainPage) {
   addPages("One", PageOne())
   addPages("Two", PageTwo())
   addPages("Three", PageThree())
  }

and if you wanna add tablayout just like this

  tabLayout = findViewById(R.id.mainTabLayout)
 
  initViewPager(R.id.mainPage , tablayout) {
   addPages("One", PageOne())
   addPages("Two", PageTwo())
   addPages("Three", PageThree())
  }

License

Copyright 2017 Alfian Yusuf Abdullah

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.