在ImageView中加載SD卡上的圖片資源
- <ImageView
- Android:id="@+id/imgView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- />
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- Button btn = (Button)findViewById(R.id.btn_b);
- btn.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- ImageView view = (ImageView)findViewById(R.id.imgView);
- String img = "/mnt/extsd/11.png";
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inSampleSize = 2;
- Log.i("chen", "============options======="+options);
- Bitmap bm = BitmapFactory.decodeFile(img, options);
- view.setImageBitmap(bm);
-
- }
- });
- }
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11