title: How to load a image from a URL into a viewpager
body: <p>i've searched the internet for this question and i couldn't find anything good.
  I did look on the <a href="http://developer.android.com/training/displaying-bitmaps/process-bitmap.html" rel="nofollow">Android Developer</a> Site but they 
  load a image from a URL into a ImageView. </p>
  
  <p>Here is my code:</p>
  
  <p>Openfactsscreen activity :</p>
  
  <pre><code>public class Openfactsscreen extends Activity {
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_openfactsscreen); 
  
          ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
          ImageAdapter adapter = new ImageAdapter(this);
          viewPager.setAdapter(adapter);
          }
  
          public void openmenu(View view){
          Intent intent = new Intent(this, SendFact.class);
          startActivity(intent); }
  
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.openfactsscreen, menu);
          return true;
   }
  
  }
  </code></pre>
  
  <p>ImageAdapter.java:</p>
  
  <pre><code>public class ImageAdapter extends PagerAdapter {
  
          Context context;
          private int[] GalImages = new int[] {
          R.drawable.factcard2,
          R.drawable.factcard8,
          R.drawable.factcard4
          };
  
  
  
          ImageAdapter(Context context){
          this.context=context;
          }
          @Override
          public int getCount() {
          return GalImages.length;
          }
  
          @Override
          public boolean isViewFromObject(View view, Object object) {
          return view == ((ImageView) object);
          }
  
          @Override
          public Object instantiateItem(ViewGroup container, int position) {
          ImageView imageView = new ImageView(context);
          int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
          imageView.setPadding(padding, padding, padding, padding);
          imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
          imageView.setImageResource(GalImages[position]);
          ((ViewPager) container).addView(imageView, 0);
          return imageView;
          }
  
          @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
          ((ViewPager) container).removeView((ImageView) object);
          }
  
  
  }
  </code></pre>
  
  <p>activity_openfactsscreen :</p>
  
  <pre><code>    &lt;RelativeLayout    xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/backgroundotheractivities" &gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/view_pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@+id/imageView1" /&gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:src="@drawable/factsscreen_layout" /&gt;
  
      &lt;ImageButton
          android:id="@+id/imageButton1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginLeft="23dp"
          android:layout_marginTop="18dp"
          android:background="@drawable/emailbutton"
          android:onClick="openmenu" /&gt;
  
      &lt;ImageButton
          android:id="@+id/imageButton2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/imageButton1"
          android:layout_toRightOf="@+id/imageButton1"
          android:background="@drawable/informationbutton" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Everything works fine, if anyone knows a good site to look on or if anyone wants to help me that would be great!</p>
  
  <p>Anyway thanks for your time and have nice day!</p>