在ImageView中显示SD卡上的图片
来源:互联网 发布:网页提取工具开发源码 编辑:程序博客网 时间:2024/05/06 02:55
在ImageView中显示SD卡上的图片
Android应用中显示SD卡上的图片可以使用ImageView,并用BitmapFactory的decodeFile读取文件。
例如在SD卡根目录下有个JPG文件DSC0001.jpg。main.xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/jpgview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/jpgview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
JAVA代码如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView jpgView = (ImageView)findViewById(R.id.jpgview);
String myJpgPath = "/sdcard/DSC_0001.JPG";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
Bitmap bm = BitmapFactory.decodeFile(myJpgPath, options);
jpgView.setImageBitmap(bm);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView jpgView = (ImageView)findViewById(R.id.jpgview);
String myJpgPath = "/sdcard/DSC_0001.JPG";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
Bitmap bm = BitmapFactory.decodeFile(myJpgPath, options);
jpgView.setImageBitmap(bm);
原文: http://www.blogjava.net/easywu/archive/2010/02/19/313416.html
- ImageView中显示SD卡上的图片或ImageView图片保存在SD卡上
- 在ImageView中显示SD卡上的图片
- ImageView中显示SD卡上的图片
- Android应用中在ImageView中显示SD卡上的图片
- Android应用中在ImageView中显示SD卡上的图片
- Android应用中在ImageView中显示SD卡上的图片
- 在ImageView中加载SD卡上的图片资源
- ImageView中的图片保存到SD卡;sd卡中图片显示在ImageView中
- 在GridView中显示SD卡上的全部图片
- imageview 显示sd卡图片
- 从SD卡上读取图片放置在ImageView上
- 【Android开发】经典范例1-在GridView中显示SD卡上的全部图片
- 加载sdcard的图片显示在ImageView中
- android ImageView-在界面中显示图片
- android 上的imageview 图片全屏显示
- 读取网络图片下载到SD卡并显示在ImageView中
- imageView显示保存在服务器的图片,不是网页上的图片
- Android如何获取网络上的图片并且显示在ImageView上
- 20111125android面试
- SunshineCharts 柱形图教程(最简单的flex Charts)
- Ubuntu vsftpd 安装配置
- AS3及Flex的常用实用问题(4)
- 《软件设计师教程》阅读小结
- 在ImageView中显示SD卡上的图片
- Intel MKL基础(2)MKL的分层结构Layered Model Concept
- 关于android里面html的应用
- Ubuntu Server最佳方案11.25
- 当前在线日志损坏,无所有数据文件备份。异常关闭(实验系列)
- 第一个JNI程序
- CListCtrl简介
- bind1st bind2nd的使用
- mongodb指南(一) - 翻译前言