0

Galleryなどの大きな画像を選択しImageView に表示しようとすると、ImageView に表示されません。

public class ColorViewerActivity extends Activity {

    // SKIP OTHER METHODS

    private static final int SELECT_PHOTO_REQUEST = 100;

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.open_image:
            selectImage();
            break;
        }
        return true;
    }

    private void selectImage() {
        Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
        photoPickerIntent.setType("image/*");
        startActivityForResult(photoPickerIntent, SELECT_PHOTO_REQUEST);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

        switch(requestCode) { 
        case SELECT_PHOTO_REQUEST:
            if (resultCode == RESULT_OK) {
                Uri imageUri = imageReturnedIntent.getData();
                ImageView imageView = (ImageView) findViewById(R.id.imageView);
                imageView.setImageURI(imageUri);
            }
        }
    }
}

どうして??画像が大きいから?

私の英語でごめんなさい。

ありがとう

4

1 に答える 1

1

メモリを超える巨大な画像を使用すると、スローされます

java.lang.OutofMemoryError: ビットマップ サイズが VM の予算を超えています。

ビットマップを効率的に表示する方法を知るには、このリンクを確認してください

于 2013-05-05T04:39:11.837 に答える