ViewPager


 

  1. Using PageAdapter
  2. Using FragmentPageAdapter
  3. With PagerTitleStrip
  4. With PagerTabStrip

 

1. Using PageAdapter

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

 

ScreenShot:

pageadapter pageadapter2 pageadapter3

Download SourceCode

 

2. Using FragmentPageAdapter 
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml file, first_frag.xml and add following code :

Step 4 : Open res -> layout -> Create new xml file, second_frag.xml and add following code :

Step 5 : Open src -> package -> MainActivity.java and add following code :

Step 6 : Open src -> package -> FirstFragment.java and add following code :

Step 7 : Open src -> package -> SecondFragment.java and add following code :

Step 8 : Open AndroidManifest.xml and add following code :

ScreenShot:

 fragadapter fragadapter2 fragadapter3

Download SourceCode

 

3. Using PagerTitleStrip 
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml file, first_frag.xml and add following code :

Step 4 : Open res -> layout -> Create new xml file, second_frag.xml and add following code :

Step 5 : Open src -> package -> MainActivity.java and add following code :

Step 6 : Open src -> package -> FirstFragment.java and add following code :

Step 7 : Open src -> package -> SecondFragment.java and add following code :

Step 8 : Open AndroidManifest.xml and add following code :

ScreenShot:

 titlestrip titlestrip2 titlestrip3

Download SourceCode

 

4. PagerTabStrip 
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml file, first_frag.xml and add following code :

Step 4 : Open res -> layout -> Create new xml file, second_frag.xml and add following code :

Step 5 : Open src -> package -> MainActivity.java and add following code :

Step 6 : Open src -> package -> FirstFragment.java and add following code :

Step 7 : Open src -> package -> SecondFragment.java and add following code :

Step 8 : Open AndroidManifest.xml and add following code :

ScreenShot:

 tabstrip tabstrip2 tabstrip3

Download SourceCode