ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


[Source] À̹ÌÁöÆÄÀÏ ´Ù¿î·Îµå
8³â Àü
// ImageDownloader.java

package co.kr.codein;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class ImageDownloader extends Activity {
  Button imageBtn;
  ImageView image;
  ProgressDialog pd;
  Handler mHandler;
  Bitmap bmp;
  String Url;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_dowload);

    mHandler = new Handler();
    Url = "http://tvzonedoc15.media.daum.net/pcp_download.php?fhandle=N2dZWkRAdHZ6b25lZG9jMTUubWVkaWEuZGF1bS5uZXQ6L0EwMDAwMDQvMjgvMjgwMi5qcGc=&filename=1.jpg";
    imageBtn = (Button) findViewById(R.id.btn);
    imageBtn.setOnClickListener(new View.OnClickListener() {

      public void onClick(View v) {
        pd = ProgressDialog.show(ImageDownloader.this,
            "Downloading Image", "Please Wait..", false);

        Thread one = new Thread() {
          public void run() {
            getFile(Url);
            mHandler.post(mUpdateResults);
          }
        };
        one.start();
      }
    });

    image = (ImageView) findViewById(R.id.my_view);
  }

  void getFile(String fileurl) {
    URL myUrl = null;
    try {
      myUrl = new URL(fileurl);

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

    try {
      HttpURLConnection conn = (HttpURLConnection) myUrl.openConnection();
      conn.connect();
      InputStream is = conn.getInputStream();
      bmp = BitmapFactory.decodeStream(is);

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

  final Runnable mUpdateResults = new Runnable() {
    public void run() {
      pd.dismiss();
      image.setImageBitmap(bmp);
      // imageBtn.setVisibility(View.INVISIBLE);
    }
  };

}

// image_dowload.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
<ImageView  
   android:id="@+id/my_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true">
  </ImageView>
  
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:text="Click"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
</Button>

</RelativeLayout>
ÃßõÃßõ : 234 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
1,166
Android WebView Facebook Login (popup/redirection issues)
1,165
Loading GIF [Android]listView ¿ø°ÝÀ̹ÌÁö [Android]
1,164
¾Û ¹öÀü üũ ½ºÅä¾î·Î À̵¿ [Android]
1,163
WebViewClient [Android]
1,162
http post get Àü¼Û
1,161
À¥ºä ¸Þ¼Òµå È£ÃâÀÌ ¾ÈµÉ ¶§ (android.permission.INTERACT_ACROSS_USERS_FULL)
1,160
°³¹ß Áß ¿¡·¯ ¹ß»ý½Ã ¿¡·¯ ³»¿ë È®ÀÎ, ÇØ°á¹æ¹ý [Android]
1,159
ij½Ã Áö¿ì±â [Android]
1,158
¹Ù·ÎÇ®¾î(¼öÇÐ ¹®Á¦ ÁúÀÇÀÀ´ä SNS) ¿¡ »ç¿ëµÈ ¿ÀǼҽº ¶óÀ̺귯¸® [Android]
1,157
¿ÀǼҽº ¶óÀ̺귯¸® ¸ðÀ½ [Android]
1,156
´Ü¸»±â ¹öÀü Á¤º¸ [Android]
1,155
Android webview °³¹ß½Ã ¾Ë¾ÆµÖ¾ß ÇÒ °Íµé [Android]
1,154
[¾Èµå·ÎÀ̵å] ¾Û ³»¿¡¼­ ·±Å¸ÀÓ ±ÇÇÑÀ» ¿äûÇÏ´Â ¹æ¹ý
1,153
webview µ¿¿µ»ó Àç»ý [Android]
1,152
android studio DefaultHttpClient, HttpClient import ¿¡·¯
1,151
[Android] ANR À̶õ?
1,150
¾Èµå·ÎÀÌµå ¿ÀǼҽº
1,149
Android] AlarmManager ÀÏÁ¤½Ã°£ À̺¥Æ® ½ÇÇà
1,148
[Android] Webview url ¼û±â±â
1,147
[Android] webview ssl ¹®Á¦
1,146
[Android] Webview 404 ¿¡·¯ ó¸®
1,145
[Android] Webview ¸Þ¼Òµå
1,144
[¾Èµå·ÎÀ̵å] À¥ºä(WebView ¿¡¼­ ÀÚ¹Ù½ºÅ©¸³Æ® alert ¶ç¿ì±â
1,143
(Android) WebView _blank ó¸®
1,142
webvew ¿¡¼­ ºê¶ó¿ìÀú·Î ¸µÅ©(_blank)
1,141
[Android]¾Èµå·ÎÀ̵å Intent »ç¿ë¹ý
1,140
¾Èµå·ÎÀÌµå ¹Ìµð¾î Ç÷¹À̾î (MediaPlayer) ¿¹Á¦
1,139
[Android] BroadcastReceiver »ç¿ëÇϱâ
1,138
Media Player¸¦ ÀÌ¿ëÇÑ À½¾Ç Àç»ý
1,137
[°³¹ß Tip] Activity³» ¹è°æÀ» Åõ¸íÇÏ°Ô Çϱâ
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.