2012-02-21 51 views
10

我正在與一個具有一種功能的應用程序一起使用,以從android內置Gallery/Camera中選擇多個圖像。在Android圖庫中選擇多個圖像

使用以下代碼,圖庫已成功打開。

Intent intent = new Intent(); 
intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE); 

但我只能從圖庫中選擇一個圖像。所以請建議我如何從內置圖庫中選擇多個圖像。

在此先感謝!

+0

你有沒有注意到你的問題至少有2個重複在stackoverflow? (http://stackoverflow.com/questions/3058922/select-multiple-images-using-galleryview) (http://stackoverflow.com/questions/4746661/select-multiple-images-from-photo-gallery- on-android-using-intents) – 2012-02-21 14:52:34

回答

1

嗯,這是一個老問題,但我想這可能對某人仍然有用。 我剛剛發佈了我的多個圖像選擇活動的源代碼。您可以在下面的GitHub庫找到它:

https://github.com/derosa/MultiImageChooser

我希望這是對您有用!

+1

這是一個很好的解決方案。儘管如此,它仍然需要改進,因爲在向下/向上滾動時它並不平滑。 – 2012-10-10 07:27:38

+0

@PareshMayani是真實的,但這與縮略圖請求方法有關。我有一天會重新編碼它使其異步。 – 2012-10-11 10:36:26

+0

我已經做到了:)將在我的博客上發佈相同的文章。 – 2012-10-11 11:50:27

1
Cursor imagecursor1 = managedQuery(
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, 
    null, orderBy + " DESC"); 

    this.imageUrls = new ArrayList<String>(); 
    imageUrls.size(); 

    for (int i = 0; i < imagecursor1.getCount(); i++) { 
    imagecursor1.moveToPosition(i); 
    int dataColumnIndex = imagecursor1 
    .getColumnIndex(MediaStore.Images.Media.DATA); 
    imageUrls.add(imagecursor1.getString(dataColumnIndex)); 
    } 

    options = new DisplayImageOptions.Builder() 
    .showStubImage(R.drawable.stub_image) 
    .showImageForEmptyUri(R.drawable.image_for_empty_url) 
    .cacheInMemory().cacheOnDisc().build(); 

    imageAdapter = new ImageAdapter(this, imageUrls); 

    gridView = (GridView) findViewById(R.id.PhoneImageGrid); 
    gridView.setAdapter(imageAdapter); 

你想更多的說明。 http://mylearnandroid.blogspot.in/2014/02/multiple-choose-custom-gallery.html