如何从imageview中删除位图?

时间:2012-12-14 11:14:06

标签: android

我正在从网址解码图像,我有一个不同网址的数组,我想显示从imageview中的网址解码的位图图像,但只显示最后一个网址的图像。我无法理解问题。

String  [] imageLocation={"http://wallbase1.org/thumbs/rozne/thumb-499842.jpg","http:   //ns3002439.ovh.net/thumbs/rozne/thumb-2493796.jpg","http://ns3002439.ovh.net/thumbs/rozne/thumb-2486664.jpg"};
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       image_view = (ImageView)findViewById(R.id.imageview);

   while(i<2)
    {
  bitmap=loadImage(imageLocation[i]);
    image_view.setImageBitmap(bitmap);

   Animation rotate = AnimationUtils.loadAnimation(LoadImageActivity.this, R.anim.rotate);
     findViewById(R.id.imageview).startAnimation(rotate);
     i++;
        }

 }

 public  Bitmap loadImage(String image_location){

      URL imageURL = null;

      try {
          imageURL = new URL(image_location);
        } 

      catch (MalformedURLException e) {
          e.printStackTrace();
        }

      try {
          HttpURLConnection connection= (HttpURLConnection)imageURL.openConnection();
          connection.setDoInput(true);
          connection.connect();
          InputStream inputStream = connection.getInputStream();


          bitmap = BitmapFactory.decodeStream(inputStream);//Convert to bitmap

      }
      catch (IOException e) {

           e.printStackTrace();
      }
    return bitmap;
 }
}

0 个答案:

没有答案