Load image from mounted sdcard : SDCard « Hardware « Android






Load image from mounted sdcard

  

package app.test;

import android.app.Activity;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;

public class Test extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          ImageView imgView = (ImageView)findViewById(R.id.image3);
          
          imgView.setImageDrawable(Drawable.createFromPath("/mnt/sdcard/d.jpg") );      
          }
}

//main.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This file is at /res/layout/list.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"  android:layout_height="fill_parent">
  <LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"  android:layout_height="fill_parent">

  <ImageView android:id="@+id/image1"
    android:layout_width="wrap_content"  android:layout_height="wrap_content"
    android:src="@drawable/icon"
    />

  <ImageView android:id="@+id/image2"
    android:layout_width="125dip"  android:layout_height="25dip"
    android:src="#555555"
    />
  </LinearLayout>
  <LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"  android:layout_height="fill_parent">

  <ImageView android:id="@+id/image3"
    android:layout_width="wrap_content"  android:layout_height="wrap_content"
    />

  <ImageView android:id="@+id/image4"
    android:layout_width="wrap_content"  android:layout_height="wrap_content"
    android:src="@drawable/icon"
    android:scaleType="centerInside"
    android:maxWidth="35dip"  android:maxHeight="50dip"
    />

  </LinearLayout>
</LinearLayout>

   
    
  








Related examples in the same category

1.Uri for sdcard
2.Get SDCard Megs Free
3.SDCard File Util
4.create File In SDCard
5.export the current database to the SDcard
6.get Sd card Path