1
アンドロイドデバイスのデフォルト画像ギャラリーをループする方法はありますか? 私のアプリでは、私は、このコードでImageViewのにデフォルトのギャラリーから選択した画像を渡すために管理している者:Androidデバイスの画像ギャラリーをループする
public void onImageGalleryClicked(View v){
//Invoke image gallery using implicit intent
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
//Where is the image gallery stored
File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
//Get path of the image gallery as string
CurrentPicturePath = pictureDirectory.getPath();
//Get the URI-representation of the image directory path
Uri data = Uri.parse(CurrentPicturePath);
//Set the data and type to get all the images
photoPickerIntent.setDataAndType(data, "image/*");
//Invoke activity and wait for result
startActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST);
}
とのViewController内で画像を表示:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK){
if(requestCode == IMAGE_GALLERY_REQUEST){
//Address of the image on SD-card
Uri imageUri = data.getData();
//Declare a stream to read the image from SD-card
InputStream inputStream;
try {
inputStream = getContentResolver().openInputStream(imageUri);
//Get a bitmap
Bitmap image = BitmapFactory.decodeStream(inputStream);
imgPicture.setImageBitmap(image);
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(this, "Unable to open image!", Toast.LENGTH_LONG).show();
}
}
}
}
今私が欲しいですデフォルトのギャラリーの次の画像を見つけるためのボタンをアプリケーションに持っています。 ギャラリーをループして、現在の画像(パス/名前で!)を探して次の画像(または前の画像)を選択できるようにしたい
[ギャラリーからアプリケーションにすべての画像をアンドロイドで読み込む](http://stackoverflow.com/questions/18590514/loading-all-the-images-from-gallery-into-the-application-インアンドロイド) – abbath