-1

我正在努力展示来自画廊的图片下面是代码。在这里,我想在特定文件夹中打开图像,名称将在编辑文本中给出。请帮助我这样做,因为它目前打开所有与应用程序无关的图像并且我很难识别图像。

protected void LoadGalleryImages() {
        final String[] columns = { MediaStore.Images.Media.DATA,
                MediaStore.Images.Media._ID };
        final String orderBy = MediaStore.Images.Media._ID;
        imagecursor = managedQuery(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
                null, orderBy);
        int image_column_index = 0;

        if (imagecursor != null) {
            image_column_index = imagecursor
                    .getColumnIndex(MediaStore.Images.Media._ID);
            count = imagecursor.getCount();
        }

        imgSelected = new String[count];

        arrPath = new String[count];
        thumbnailsselection = new boolean[count];
        for (int i = 0; i < count; i++) {
            if (imagecursor != null) {
                imagecursor.moveToPosition(i);
                // int id = imagecursor.getInt(image_column_index);
                int dataColumnIndex = imagecursor
                        .getColumnIndex(MediaStore.Images.Media.DATA);

                arrPath[i] = imagecursor.getString(dataColumnIndex);
            }

        }
    }
4

1 回答 1

0

普加,

这是打开指定文件夹以浏览文件的代码:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse("folder path");

//Change content type as you want if you dont know then just mention "*/*"
intent.setDataAndType(uri, "text/csv");

startActivity(Intent.createChooser(intent, "Open folder"));

希望这会帮助你。

于 2013-12-16T08:14:42.210 回答