在ImageView中加载SD卡上的图片资源
1. <ImageView
2. android:id="@+id/imgView"
3. android:layout_width="fill_parent"
4. android:layout_height="fill_parent"
5. />
1. public void onCreate(Bundle savedInstanceState) {
2. super.onCreate(savedInstanceState);
3. setContentView(R.layout.main);
4.
5. Button btn = (Button)findViewById(R.id.btn_b);
6. btn.setOnClickListener(new View.OnClickListener() {
7.
8. @Override
9. public void onClick(View v) {
10. ImageView view = (ImageView)findViewById(R.id.imgView);
11. String img = "/mnt/extsd/11.png";
12. BitmapFactory.Options options = new BitmapFactory.Options();
13. options.inSampleSize = 2;
14. Log.i("chen", "============options======="+options);
15. Bitmap bm = BitmapFactory.decodeFile(img, options);
16. view.setImageBitmap(bm);
17.
18. }
19. });
20. }
作者:chenshijun0101
补充:移动开发 , Android ,