package com.example.test
import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URL;
import java.net.URLConnection;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.provider.SyncStateContract.Constants;
import android.widget.ImageView;
import android.widget.ViewFlipper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.provider.SyncStateContract.Constants;
import android.widget.ImageView;
import android.widget.ViewFlipper;
public class s_imgViewMain extends Activity {
ImageView imgView;
ViewFlipper flipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgView = (ImageView)findViewById(R.id.imgView);
flipper = (ViewFlipper)findViewById(R.id.flipper);
try {
URL url = new URL("이미지 주소");
URLConnection conn = url.openConnection();
conn.connect();
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
imgView.setImageBitmap(bm);
} catch (Exception e) {
}
}
}
ImageView imgView;
ViewFlipper flipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgView = (ImageView)findViewById(R.id.imgView);
flipper = (ViewFlipper)findViewById(R.id.flipper);
try {
URL url = new URL("이미지 주소");
URLConnection conn = url.openConnection();
conn.connect();
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
imgView.setImageBitmap(bm);
} catch (Exception e) {
}
}
}
주의사항!!
퍼미션 추가
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
댓글 없음:
댓글 쓰기