package com.example.macbookpro.khoaphamtaihinhtuinternet; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; public class MainActivity extends AppCompatActivity { ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); img = (ImageView) findViewById(R.id.img); try { URL url = new URL("http://i615.photobucket.com/albums/tt239/lamson1207/20151002_212132_zpsa2uhykn2.jpg"); Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream()); img.setImageBitmap(bmp); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
Friday, July 1, 2016
Tải hình từ internet trên android 2.3.3
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment