  | 
  |   
 |   | 
| [Source] URLÀ» ÅëÇÑ À̹ÌÁö µå·ÎÀ× | 
 |   
 |  
    | 
9³â Àü |  
  // GraphicsSample.java 
package co.kr.codein; 
 
import java.io.InputStream; 
import java.net.URL; 
 
import android.app.Activity; 
import android.graphics.drawable.Drawable; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.Window; 
import android.widget.ImageView; 
import android.widget.TextView; 
 
/** 
 *  
 * @author Áø¿ëÈÆ 
 * @since 2009/1/4 
 *  
 */ 
public class GraphicsSample extends Activity { 
 
  final String LOG_TAG = "GraphicsSample"; 
 
  /** Called when the activity is first created. */ 
  @Override 
  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.main); 
 
    ImageView view = (ImageView) findViewById(R.id.picture); 
    String urlStr = "http://pds45.cafe.daum.net/image/10/cafe/2007/08/04/16/36/ 
46b42c968f8f3"; 
    Drawable draw = loadDrawable(urlStr); 
    // view.setBackgroundColor(color.white); 
    view.setImageDrawable(draw); 
     
    TextView text = (TextView) findViewById(R.id.label); 
    text.setText("À̹ÌÁö µå·ÎÀ×?~"); 
  } 
 
  /** 
   *  
   * @param urlStr 
   */ 
  public Drawable loadDrawable(String urlStr) { 
    Drawable drawable = null; 
 
    // ?? 1> 
    // Uri uri = 
    // Uri.parse("http://www.yexing.org/image.axd?picture=browse.png"); 
    // iv.setImageURI(uri); 
 
    try { 
      URL url = new URL(urlStr); 
      InputStream is = url.openStream(); 
      drawable = Drawable.createFromStream(is, "none"); 
    } catch (Exception e) { 
      Log.e(LOG_TAG, "error, in loadDrawable \n" + e.toString()); 
    } 
 
    return drawable; 
  } 
} 
  
// main.xml 
  
<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
    android:layout_width="fill_parent"   
    android:layout_height="fill_parent"   
    android:orientation="vertical"   
>   
    <ImageView   
        android:id="@+id/picture"  
        android:paddingTop="2px" 
        android:layout_width="fill_parent"   
        android:layout_height="wrap_content" 
    />   
    <TextView   
        android:id="@+id/label"   
        android:layout_width="fill_parent"   
        android:layout_height="wrap_content"   
        android:textSize="12sp" 
        android:background="#FF0000FF" 
    /> 
</LinearLayout> 
 |  
  
 |  
 ̵̧ : 440 | 
̵̧
¸ñ·Ï
 |   
 |  
  |   | 
 |