티스토리 뷰

package com.example.test

 

import java.io.BufferedInputStream;
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;

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) {
  }
        
    }
}

 

 

주의사항!!

퍼미션 추가

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

 


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함