在显示存储在Android中的特定文件夹中的所有图像打开photoviewer问题 [英] problem in opening photoviewer for displaying all the images stored in a particular folder in android

查看:273
本文介绍了在显示存储在Android中的特定文件夹中的所有图像打开photoviewer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动(MyActivity),其中我有一个网格视图。我也有从媒体库新增现有的照片按钮。当我们点击这个按钮,它会打开画廊浏览器应用程序,并在图片库中选取任何照片后,将更新MyActivity GridView控件。
我也是存储在MYIMAGE文件夹中所选照片的​​SD卡。

I have one activity(MyActivity), in which I have a grid view. Also I have the "add existing photo from gallery " button. When we click on this button it will open the gallery viewer application and after selecting any photo in gallery it will update the gridview in MyActivity. Also I am storing the selected photos in the myimage folder in sdcard.

我想,如果我将选择在网格视图中任何特定的电池它会打开photoviewer,显示该文件夹(MYIMAGE)所有图像present。

I want that if I will select any particular cell in grid view it will open the photoviewer to display all the images present in that folder (myimage).

在code以下

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
        try {

        Intent intent = new Intent(Intent.ACTION_VIEW);

        intent.setDataAndType(Uri.parse("file:///sdcard/myimage/*"), 
        "image/*"); 

        startActivity(intent); 

}

这code,在点击网格视图中特定的细胞,打开photoviewer,但没有显示该文件夹中的所有照片。

This code, on clicking particular cell of grid view, opens the photoviewer, but not showing any photos in that folder.

但是,如果我用这个code

But if I use this code

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
        try {

        Intent intent = new Intent(Intent.ACTION_VIEW);

        intent.setDataAndType(Uri.parse("file:///sdcard/myimage/a.jpg"), 
        "image/*"); 

        startActivity(intent); 

}

这是只显示照片A.JPG,不是所有的照片在MYIMAGE文件夹中。也没有显示在photoviewer下一个和previous箭头。

it is showing only the photo a.jpg, not all the photos in the myimage folder. Also not showing the next and previous arrow in the photoviewer.

我要显示在SD卡旁边和previous特定文件夹中的所有图像present箭头的话,那我们可以通过所有照片穿越。

I want to display all the images present in a particular folder in sd card with next and previous arrow so, that we can traverse through all the photos.

如果这是不可能用这种方法,建议我另一种方法(请附上code也)。

If this is not possible in this way, suggest me other approach(please attach the code also).

推荐答案

使用下面的逻辑来获得在画廊所有图像present的路径。
创建您自己的PhotoGrid显示所有图像。写独立的活动,你有一个图像视图来显示图像和明年或previous按钮。如果单击下一步按钮增加计数器设定的图像,在ArrayList的那个位置present。

Use the following logic to get path of all images present in gallery. Create your own PhotoGrid to display all images. write separate activity where you have an image view to show the image and next or previous buttons. if you click next button increase the counter set image which is present in that position in ArrayList.

ArrayList<String> listOfAllImages = new ArrayList<String>();
String absolutePathOfImage = null;
uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

            String[] projection = { MediaColumns.DATA,
                    MediaColumns.DISPLAY_NAME };

            cursor = activity.managedQuery(uri, projection, null, null, null);
            column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
while (cursor.moveToNext()) {
absolutePathOfImage = cursor.getString(column_index);
listOfAllImages.add(absolutePathOfImage);
}

谢谢
迪帕克

Thanks Deepak

这篇关于在显示存储在Android中的特定文件夹中的所有图像打开photoviewer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆