Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 活动中未显示图像_Android - Fatal编程技术网

Android 活动中未显示图像

Android 活动中未显示图像,android,Android,我正在处理一个文件夹中的图像,并将其保存在内存中的其他文件夹中。其他活动显示除我正在处理的图像之外的所有图像,但这些图像正在保存在内存中,因为我可以通过文件管理器进行检查 Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; Cursor cursor = getContentResolver().query(uri, null, null, null, null); listItem = new ArrayList<ImageIt

我正在处理一个文件夹中的图像,并将其保存在内存中的其他文件夹中。其他活动显示除我正在处理的图像之外的所有图像,但这些图像正在保存在内存中,因为我可以通过文件管理器进行检查

Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
listItem = new ArrayList<ImageItem>();
cursor.moveToFirst();
uriuri=MediaStore.Images.Media.EXTERNAL\u CONTENT\u Uri;
Cursor Cursor=getContentResolver().query(uri,null,null,null,null);
listItem=新的ArrayList();
cursor.moveToFirst();

您的URI是否正确?检查两次。在填充UI和相关代码时显示代码。如果没有适当的代码示例和足够的解释,阅读您的问题的人很难猜测您是否获得了正确的URI?检查两次。在填充UI和相关代码时显示代码。如果没有适当的代码示例和足够的解释,阅读您的问题的人很难猜测
    //Pick image. 
    Uri selectedImage = data.getData();
                    String[] filePathColumn = {MediaStore.Images.Media.DATA};

                    Cursor cursor = getContentResolver().query(selectedImage,
                            filePathColumn, null, null, null);
                    cursor.moveToFirst();

                    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                    String picturePath = cursor.getString(columnIndex);
                    cursor.close();

    // method for save image
private void createDirectoryAndSaveFile(Bitmap imageToSave, String fileName) {

    File direct = new File(Environment.getExternalStorageDirectory() + "/Folder Name");
    File file = new File(direct);
    if (!file.exists()) {
        file.mkdir();
    }
 file = new File(file, fileName);
    try {
        FileOutputStream out = new FileOutputStream(file);
        imageToSave.compress(Bitmap.CompressFormat.JPEG, 100, out);
        out.flush();
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}