package com.example.viewpager01;

//http://www.whycouch.com/2012/12/the-simplest-way-to-use-viewpager.html

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.TextView;
 
public class MainActivity extends FragmentActivity {
 
    ViewPager pager;
    FragmentStatePagerAdapter adapter; 
   
  
    /* Just some random URLs
    * 
    * Each page of our pager will display one URL from this array
    * Swiping, to the right will take you to the next page having
    * the next URL.
    */
    /*
     String[] toVisit={
        "http://www.free.fr",
        "http://www.google.com",
        "http://www.sfr.fr",
        "http://www.ldlc.com",
    };
  
     */
/*
    String[] toVisit={
    	        "http://www.analog-design.net/ALARME/aaa.jpg",
    	        "http://www.analog-design.net/ALARME/bbb.jpg",
    	        "http://www.analog-design.net/ALARME/ccc.jpg",
    	        "http://www.ldlc.com",
    	    };
 */    
     
     String[] toVisit={
 	        "file://mnt/sdcard/tmp.jpg",
 	        "file://mnt/sdcard/recu.jpg",
 	       "file://mnt/sdcard/test.jpg",
 	      "file://mnt/sdcard/downloadedfile.jpg"
 	        
 	    };
     
    // String path = "file://mnt/sdcard/tmp.jpg";
    //picView.loadUrl(path);
     
//	android:layout_gravity="center"
//  android:layout_centerHorizontal="true"
//  android:layout_centerVertical="true"

     
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        pager=(ViewPager)findViewById(R.id.my_pager);
      
        
        
        adapter=new FragmentStatePagerAdapter( getSupportFragmentManager())
        {
	            @Override
	            public int getCount() {
	                // This makes sure getItem doesn't use a position
	               // that is out of bounds of our array of URLs
	               return toVisit.length;
	            }
	    
	            @Override
	            public Fragment getItem(int position)
	            {
	                // Here is where all the magic of the adapter happens
	                // As you can see, this is really simple.
	            	
	            	
	                return BrowserFragment.newInstance(toVisit[position]);
	            }
        };
   
        //Let the pager know which adapter it is supposed to use
        pager.setAdapter(adapter);  
    }  
}