【发布时间】:2012-06-12 20:55:58
【问题描述】:
我正在尝试将 .jpg 从我的 sd 卡显示到我的布局中的图像视图中。我没有收到任何错误,但没有显示任何内容。我将不胜感激任何帮助。谢谢
编辑:
layout1 = (LinearLayout) findViewById(R.id.layout1Activity);
String imgFile = Environment.getExternalStorageDirectory() + "/Apple.jpg";
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile);
ImageView myImage = new ImageView(this);
myImage.setImageBitmap(myBitmap);
layout1.addView(myImage);
【问题讨论】:
-
您的代码中似乎缺少
"... -
你写的是 getExternalStorageState() 而不是 getExternalStorageDirectory(),你可以从我的回答中复制它。
-
糟糕!改变它,它的工作原理!感谢您的帮助!
-
我认为你需要这个 stackoverflow.com/questions/6224710/…> 我发现它很有用。
标签: android bitmap android-imageview